This is a migrated thread and some comments may be shown as answers.

Dynamically adding Checkbox within DataGridView

2 Answers 90 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jerry
Top achievements
Rank 1
jerry asked on 19 Mar 2009, 09:11 PM
I'm using the code from the help to create a Checkbox within my datagridview

     GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn();  
      checkBoxColumn.DataType = typeof(int);  
      checkBoxColumn.UniqueName = "Selected";  
      checkBoxColumn.FieldName = "Selected";  
      checkBoxColumn.HeaderText = "";  
      radGVTables.MasterGridViewTemplate.Columns.Add(checkBoxColumn); 

Then I set the data souce equal to my oracle query.  The first time around it's fine but when I make a change to one of the drop downs the data changes so I remove this column and readd it but it keeps adding it to the end of the grid instead of position zero like I need it to be.  What is the best way around this?

Also why when I rebind to my datagridview does the checkbox still stay checked?  Do I have to remove and readd the column everytime?


Thank You

2 Answers, 1 is accepted

Sort by
0
jerry
Top achievements
Rank 1
answered on 20 Mar 2009, 02:00 PM
Any help on this one?
0
Nick
Telerik team
answered on 20 Mar 2009, 06:07 PM
Hi jerry,

Thank you for your questions. The answer to your first question is to use the Move method of the Columns collection:

this.radGridView1.Columns.Move(0, 5); 

You second forum post seems like a more detailed version of your second question, so we will answer it there.

Please, note that our respond time for trial users is 72 hours, and are only guaranteed through the usage of our support ticketing system. Although we review all Forum posts, they are not guaranteed a response.

Please do not hesitate to write me if you encounter other questions. I hope your trial period is going fine.  

 
Sincerely yours,
Nick
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
jerry
Top achievements
Rank 1
Answers by
jerry
Top achievements
Rank 1
Nick
Telerik team
Share this question
or