T
Thomas A
Hi !
I'm trying to use a datagrid with an checkbox column, I not shoure to
get it work on several points
I have got the rest of the data mapped to the grid but the checkbox
doesnt work.
1. The column type in the sql is Integer (values 0 or 1), is this ok or
should I change it to something else?
2. my code to load the grid
Sub LoadDataToGrid()
formatdatagrid()
DataSet11.Clear()
DataGrid1.DataSource = (DataSet11)
DataGrid1.DataMember = "RAT_Customer"
SqlDataAdapter1.SelectCommand.CommandText = "Select CustomerCode
as KundNr, SL01002 as KundNamn ,Pfaktor as Påslag, InOutputFile from
RAT_Customer, SL010100 where CustomerCode = SL01001"
SqlConnection1.Open()
SqlDataAdapter1.Fill(DataSet11)
SqlConnection1.Close()
End Sub
3. My code to format the grid
Dim grdColStyle1 As New DataGridTextBoxColumn
With grdColStyle1
.HeaderText = "Kund Nr"
.MappingName = "KundNr"
.Width = 50
End With
Dim grdColStyle2 As New DataGridTextBoxColumn
With grdColStyle2
.HeaderText = "Namn"
.MappingName = "KundNamn"
.Width = 90
End With
Dim grdColStyle3 As New DataGridTextBoxColumn
With grdColStyle3
.HeaderText = "Påslag traktamente (SEK)"
.MappingName = "Påslag"
.Width = 140
'.ReadOnly = True
End With
Dim grdColStyle4 As New DataGridBoolColumn
With grdColStyle4
.HeaderText = "Överföring till RAT"
.MappingName = "InOutputFile"
.Width = 130
.Alignment = HorizontalAlignment.Center
.ReadOnly = False
End With
' Add the style objects to the table style's collection of
' column styles. Without this the styles do not take effect.
grdTableStyle1.GridColumnStyles.AddRange _
(New DataGridColumnStyle() _
{grdColStyle1, grdColStyle2, grdColStyle3, grdColStyle4})
DataGrid1.TableStyles.Add(grdTableStyle1)
I should be very happy if anyone could tell whats wrong or whats missing
I'm trying to use a datagrid with an checkbox column, I not shoure to
get it work on several points
I have got the rest of the data mapped to the grid but the checkbox
doesnt work.
1. The column type in the sql is Integer (values 0 or 1), is this ok or
should I change it to something else?
2. my code to load the grid
Sub LoadDataToGrid()
formatdatagrid()
DataSet11.Clear()
DataGrid1.DataSource = (DataSet11)
DataGrid1.DataMember = "RAT_Customer"
SqlDataAdapter1.SelectCommand.CommandText = "Select CustomerCode
as KundNr, SL01002 as KundNamn ,Pfaktor as Påslag, InOutputFile from
RAT_Customer, SL010100 where CustomerCode = SL01001"
SqlConnection1.Open()
SqlDataAdapter1.Fill(DataSet11)
SqlConnection1.Close()
End Sub
3. My code to format the grid
Dim grdColStyle1 As New DataGridTextBoxColumn
With grdColStyle1
.HeaderText = "Kund Nr"
.MappingName = "KundNr"
.Width = 50
End With
Dim grdColStyle2 As New DataGridTextBoxColumn
With grdColStyle2
.HeaderText = "Namn"
.MappingName = "KundNamn"
.Width = 90
End With
Dim grdColStyle3 As New DataGridTextBoxColumn
With grdColStyle3
.HeaderText = "Påslag traktamente (SEK)"
.MappingName = "Påslag"
.Width = 140
'.ReadOnly = True
End With
Dim grdColStyle4 As New DataGridBoolColumn
With grdColStyle4
.HeaderText = "Överföring till RAT"
.MappingName = "InOutputFile"
.Width = 130
.Alignment = HorizontalAlignment.Center
.ReadOnly = False
End With
' Add the style objects to the table style's collection of
' column styles. Without this the styles do not take effect.
grdTableStyle1.GridColumnStyles.AddRange _
(New DataGridColumnStyle() _
{grdColStyle1, grdColStyle2, grdColStyle3, grdColStyle4})
DataGrid1.TableStyles.Add(grdTableStyle1)
I should be very happy if anyone could tell whats wrong or whats missing