| | |
C#Net2003 - Add CheckBox in DataGrid
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 45
Reputation:
Solved Threads: 8
0
#2 25 Days Ago
Just Create OneTemplatecolumn like
<Columns>,in item template add one checkbox
<Columns>,in item template add one checkbox
Chandru
SilverlightScripting.com
SilverlightScripting.com
•
•
Join Date: Jul 2009
Posts: 117
Reputation:
Solved Threads: 10
0
#3 25 Days Ago
•
•
•
•
Hi there,
Please help me. I am having problem trying to include Checkbox in 1st Column in DataGrid for all the Rows. Being a newbie and I am struggling doing it. I need your help.
You have to use tablestyles while binding the data to grid,
Create DataGridColumnStyle for each column.
for first column if u need check box follow this code.
C# Syntax (Toggle Plain Text)
DataGridTableStyle tblstyle = new DataGridTableStyle(); DataGridBoolColumn chkboxCol=new DataGridBoolColumn(); discontinuedCol.MappingName = "chkbox"; discontinuedCol.HeaderText = ""; discontinuedCol.Width = 30; chkboxCol.AllowNull = false; tblstyle .GridColumnStyles.Add(chkboxCol);
Hope it helps..............
Last edited by vinnijain; 25 Days Ago at 5:35 am.
•
•
Join Date: Jul 2009
Posts: 117
Reputation:
Solved Threads: 10
0
#4 25 Days Ago
You can also read the article in following link:
http://www.dotnetspark.com/kb/151-ad...w-windows.aspx
http://www.dotnetspark.com/kb/151-ad...w-windows.aspx
•
•
Join Date: Mar 2006
Posts: 26
Reputation:
Solved Threads: 0
0
#5 25 Days Ago
Hi Vinnijain
C#.NET 2003 - Window Application.
I have tried out your suggestion and here is my overall script to add CheckBox into First Column and in every row in the DataGrid.
On compilation I got this error message:-The type or namespace name 'discontinuedCol' could not be found (are you missing a using directive or an assembly reference?)
Sample Script:-
C#.NET 2003 - Window Application.
I have tried out your suggestion and here is my overall script to add CheckBox into First Column and in every row in the DataGrid.
On compilation I got this error message:-The type or namespace name 'discontinuedCol' could not be found (are you missing a using directive or an assembly reference?)
Sample Script:-
c# Syntax (Toggle Plain Text)
private void FFormatDataGridColumn() { DataGridTableStyle DGTStyle = new DataGridTableStyle(); DGTStyle.MappingName = "CustomerTbl"; CheckBox chkbox = new CheckBox(); // 1st column checkbox DataGridBoolColumn chkboxCol = new DataGridBoolColumn(); discontinuedCol.MappingName = "chkbox" ; discontinuedCol.HeaderText = "Select"; discontinuedCol.Width = 30; discontinuedCol.AllowNull = false; //column 2 DataGridColumnStyle DGTcol2 = new DataGridTextBoxColumn(); DGTcol2.MappingName = "CustID"; DGTcol2.HeaderText ="Customer ID"; DGTcol2.Width =50; //column 3 DataGridColumnStyle DGTcol3 = new DataGridTextBoxColumn(); DGTcol3.MappingName = "FirstName"; DGTcol3.HeaderText = "First NameAA"; DGTcol3.Width =150; //column 4 DataGridColumnStyle DGTcol4 = new DataGridTextBoxColumn(); DGTcol4.MappingName = "LastName"; DGTcol4.HeaderText = "Last NameBB"; DGTcol4.Width = 150; //add column to DGTStyle DGTStyle.GridColumnStyles.Add(chkboxCol); DGTStyle.GridColumnStyles.Add(DGTcol2); DGTStyle.GridColumnStyles.Add(DGTcol3); DGTStyle.GridColumnStyles.Add(DGTcol4); dataGrid1.TableStyles.Add(DGTStyle); }
Last edited by peter_budo; 24 Days Ago at 4:12 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Have a Good Day.
Cheers,
Lennie
Cheers,
Lennie
•
•
Join Date: Jul 2009
Posts: 117
Reputation:
Solved Threads: 10
0
#6 25 Days Ago
Add the following line in your code:
C# Syntax (Toggle Plain Text)
DataGridBoolColumn discontinuedCol=new DataGridBoolColumn();
•
•
Join Date: Mar 2006
Posts: 26
Reputation:
Solved Threads: 0
0
#7 25 Days Ago
Hi Vinnijian,
I have change the script as per below based on your suggestion. The DataGrid does displays the row of data but it's without the CheckBox.
Not sure why it's not working.
Please Help. Thanks
I have change the script as per below based on your suggestion. The DataGrid does displays the row of data but it's without the CheckBox.
Not sure why it's not working.
Please Help. Thanks
C# Syntax (Toggle Plain Text)
CheckBox chkbox = new CheckBox(); DataGridBoolColumn discontinuedCol = new DataGridBoolColumn(); discontinuedCol.MappingName = "chkbox "; discontinuedCol.HeaderText = "Select"; discontinuedCol.Width = 30; discontinuedCol.AllowNull = false; //add column to DGTStyle DGTStyle.GridColumnStyles.Add(discontinuedCol); DGTStyle.GridColumnStyles.Add(DGTcol2); DGTStyle.GridColumnStyles.Add(DGTcol3); DGTStyle.GridColumnStyles.Add(DGTcol4); dataGrid1.TableStyles.Add(DGTStyle);
Last edited by LennieKuah; 25 Days Ago at 3:20 am. Reason: type error
Have a Good Day.
Cheers,
Lennie
Cheers,
Lennie
•
•
Join Date: Jul 2009
Posts: 117
Reputation:
Solved Threads: 10
0
#8 25 Days Ago
Read the following article :
http://www.vbdotnetheaven.com/Upload...gDatagrid.aspx
Hope it will help....
http://www.vbdotnetheaven.com/Upload...gDatagrid.aspx
Hope it will help....
•
•
Join Date: Mar 2006
Posts: 26
Reputation:
Solved Threads: 0
0
#9 24 Days Ago
Hi Vinnijian,
I did have a look at the URL site with VB format script and compared it with my C# format script. Logically it looks very similiar. The VB script end result shows the DataGrid with CheckBox but not my version. I am very puzzled.
HELP.........PLEASE HELP.........
I did have a look at the URL site with VB format script and compared it with my C# format script. Logically it looks very similiar. The VB script end result shows the DataGrid with CheckBox but not my version. I am very puzzled.
HELP.........PLEASE HELP.........
Have a Good Day.
Cheers,
Lennie
Cheers,
Lennie
![]() |
Similar Threads
- How can I add a checkbox to a datagrid? (ASP.NET)
- How to add a colimn in Datagrid at runtime (C#)
- Checkbox in Datagrid has to click twice to uncheck. (VB.NET)
- to add checkbox in asp.net in gridview (ASP.NET)
- How to add a new row to a datagrid (C#)
- Selcet/Deselcet All checkbox in Datagrid using Javascript (JavaScript / DHTML / AJAX)
- add column to datagrid form dropdownlist selectitem (VB.NET)
- checkbox in datagrid (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: C# Maximized Forms Are Still Movable And resizeable
- Next Thread: Where Can I get a C# Compiler
| Thread Tools | Search this Thread |
.net access algorithm array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop picturebox pixelinversion platform post programming radians regex remote remoting resourcefile richtextbox server sleep socket sql statistics stream string system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml





