|
-
July 10th, 2007, 11:54 PM
#1
Automatically checked for dynamic check box in datagrid view
Hi,
I have a checkbox that is dynamically added to the datagridview.I would like to have the checked box checked automatically when it is created.I do not want to loop the datagridview to get the checked box checked which work like this:
Code:
this.dataGridView1.Rows[RowIndex].Cells[ColumnIndex].Value = true
I find no ways to do this.Below is my coding:
Code:
DataGridView1.Columns.Add(CreateCheckBoxColumn)
Private Function CreateCheckBoxColumn() As DataGridViewCheckBoxColumn
Dim dataGridViewCheckBoxColumn1 _
As New DataGridViewCheckBoxColumn()
dataGridViewCheckBoxColumn1.HeaderText = "Insert"
dataGridViewCheckBoxColumn1.TrueValue = True
dataGridViewCheckBoxColumn1.FalseValue = False
dataGridViewCheckBoxColumn1.IndeterminateValue = 3
dataGridViewCheckBoxColumn1.ThreeState = True
Return dataGridViewCheckBoxColumn1
Return dataGridViewCheckBoxColumn1
End Function
Does anyone has idea on dooing this?
-
July 11th, 2007, 02:42 AM
#2
Re: Automatically checked for dynamic check box in datagrid view
Use RowsAdded eveent to set the checkBoxCOlumns value to true
Code:
Private Sub DataGridView1_RowsAdded(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs) Handles DataGridView1.RowsAdded
DataGridView1.Rows(e.RowIndex).Cells(DataGridView1.Columns("Insert").Index).Value = True
End Sub
Also add this to initialization of checkboxColumn
Code:
dataGridViewCheckBoxColumn1.Name = "Insert"
-
July 11th, 2007, 06:27 AM
#3
Re: Automatically checked for dynamic check box in datagrid view
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|