Create checkbox in gridview column at runtime

  • Thread starter Thread starter Tony WONG
  • Start date Start date
T

Tony WONG

The gridview is created at runtime

there is a column for checkbox (non-databind)

i can create a blank column by the code

Dim tfSelect As New TemplateField
tfSelect.ItemStyle.Width = 80
mygrid.Columns.Add(tfSelect)

but i do not know how to add the checkbox in the column

grateful for any assistance.

thanks.

tony
 
The gridview is created at runtime

there is a column for checkbox (non-databind)

i can create a blank column by the code

Dim tfSelect As New TemplateField
tfSelect.ItemStyle.Width = 80
mygrid.Columns.Add(tfSelect)

but i do not know how to add the checkbox in the column

Not quite sure if the syntax is correct as I never go anywhere near VB.NET,
but it's probably something like:

Dim MyCB As New CheckBox
' set any properties on MyCB as necessary
mygrid.Columns(0).Controls.Add(MyCB)

Obviously, you'll need to modify the column number in the third line
above...

Alternatively, you may be able to do this with the tfSelect object directly,
e.g.

Dim tfSelect As New TemplateField
tfSelect.ItemStyle.Width = 80
Dim MyCB As New CheckBox
tfSelect.Controls.Add(MyCB)
mygrid.Columns.Add(tfSelect)
 
Thanks a lot.

i can't do it with just a line of code

finally i make it by refering a Class.
 
Back
Top