Hi,
I have a column with ColumnStyle.CheckBox, it is a unbound column. The column shows null value after I execute SetDataBinding. I wanna shows checked or unchecked state , I think there is a default value for me, How I do?
Thanks!
Hi Jason,
You can set the DefaultCellValue property on the column.
But it seems not work well. I set the defaultcellvalue in InitializeLayout ,and when a button click for call SetDataBinding. when DefaultCellValue = False ,it works well ,but when DefaultCellValue = True , it is not ok, it always show the False state. it is my test code. by the way , when I set the column datatype as string , it is not work well yet.
Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout UltraGrid1.DisplayLayout.AddNewBox.Hidden = False
With e.Layout.Bands(0) If Not .Columns.Exists("COL1") Then .Columns.Add("COL1") .Columns("COL1").DataType = GetType(Boolean) .Columns("COL1").DefaultCellValue = True End If If Not .Columns.Exists("COL2") Then .Columns.Add("COL2") .Columns("COL2").DataType = GetType(String) End If End With End Sub
Private Sub UltraButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton1.Click UltraGrid1.SuspendLayout()
Dim dt As New DataTable Dim dr As DataRow dt.Columns.Add("COL2", GetType(String)) For i As Integer = 0 To 9 dr = dt.NewRow dr.Item("COL2") = CStr(i + 4) dt.Rows.Add(dr) Next dt.AcceptChanges() UltraGrid1.SetDataBinding(dt, Nothing, True)
End Sub