I have a checkbox in a datagridview and it is passing a null value instead of a false/0 when user doesn't click on it. How can I change it, so it passes a value. I already tried passing values explicityly through the bounddatacolumn properties in the datagridview... |
| ChitownDotNet Tuesday, September 12, 2006 4:20 PM |
Unfortunately none of the solutions suggested worked. Here is what worked for me: The value passed is not even null. there fore I had to convert to a string and then compare its length..
private void DGView_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { int RowEdited = e.RowIndex; if (DGView["MfgColumn", RowEdited].Value.ToString().Length <= 0) DGView["MfgColumn", RowEdited].Value = 0; }
|
| ChitownDotNet Friday, September 15, 2006 7:43 PM |
|
| Ken Tucker Tuesday, September 12, 2006 4:37 PM |
It's already set to False..I checked from the designer. |
| ChitownDotNet Tuesday, September 12, 2006 6:23 PM |
Somebody has gotta know the answer for this :) |
| ChitownDotNet Wednesday, September 13, 2006 7:55 PM |
How are you getting the values?This works for me
| |
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim chkCol As New DataGridViewCheckBoxColumn chkCol.Name = "CheckMe" chkCol.HeaderText = "Check Me" DataGridView1.Columns.Add(chkCol) DataGridView1.AllowUserToAddRows = False DataGridView1.RowCount = 5 For Each r As DataGridViewRow In DataGridView1.Rows Dim val As Boolean val = CBool(r.Cells(0).Value) Trace.WriteLine(val) Next End Sub
End Class
|
|
| Ken Tucker Thursday, September 14, 2006 1:56 AM |
Have you modified the DataGridViewCheckBoxCell.ThreeState property? |
| Wang Chi Thursday, September 14, 2006 1:57 AM |
Unfortunately none of the solutions suggested worked. Here is what worked for me: The value passed is not even null. there fore I had to convert to a string and then compare its length..
private void DGView_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { int RowEdited = e.RowIndex; if (DGView["MfgColumn", RowEdited].Value.ToString().Length <= 0) DGView["MfgColumn", RowEdited].Value = 0; }
|
| ChitownDotNet Friday, September 15, 2006 7:43 PM |