datagrid add checkboxes

M

Maarten

i have the folowing code to setup my datagrid collumns

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

gridsetup()

end sub



Private Sub gridsetup()

O.Columns.Add("Channel")

O.Columns.Add("Name")

O.Columns.Add("Status")

O.Columns.Add("On")

O.Columns.Add("Time Modified")

DataGrid1.DataSource = O

End Sub

then i can add rows with some more code

but now my question is, how can y simply add a collumn with checkboxes



thanks Maarten
 
M

Maarten

indeed i went to the link yesterday, but the code ther looks all so complex
they generate the controls at runtime, and i can't figure out how to make a
collumstyle.

i added tried to shange some code to let the grid display a column with
checkboxes with my databinding, but it won't work.

i hope someone can help me

kind regards Maarten
 
M

Maarten

ok i found some code to setup the table, and se collums.

but how can add some cource.

i tried to do so, but the styles do not effect the grid.

this is what i did.



Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

FormatGridWithBothTableAndColumnStyles()

addata()

End Sub

Private Sub FormatGridWithBothTableAndColumnStyles()

With DataGrid1

..BackColor = Color.GhostWhite

..BackgroundColor = Color.Lavender

..BorderStyle = BorderStyle.None

..CaptionBackColor = Color.RoyalBlue

..CaptionFont = New Font("Tahoma", 10.0!, FontStyle.Bold)

..CaptionForeColor = Color.Bisque

..CaptionText = "Northwind Products"

..Font = New Font("Tahoma", 8.0!)

..ParentRowsBackColor = Color.Lavender

..ParentRowsForeColor = Color.MidnightBlue

..DataSource() = D

End With

Dim grdTableStyle1 As New DataGridTableStyle()

With grdTableStyle1

..AlternatingBackColor = Color.GhostWhite

..BackColor = Color.GhostWhite

..ForeColor = Color.MidnightBlue

..GridLineColor = Color.RoyalBlue

..HeaderBackColor = Color.MidnightBlue

..HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)

..HeaderForeColor = Color.Lavender

..SelectionBackColor = Color.Teal

..SelectionForeColor = Color.PaleGreen

..MappingName = "Controler"

..PreferredColumnWidth = 125

..PreferredRowHeight = 15

End With

Dim grdColStyle1 As New DataGridBoolColumn()

With grdColStyle1

..HeaderText = "On/Off"

..MappingName = "ID"

..Width = 50

End With

Dim grdColStyle2 As New DataGridTextBoxColumn()

With grdColStyle2

..HeaderText = "Name"

..MappingName = "ChannelName"

End With

Dim grdColStyle3 As New DataGridTextBoxColumn()

With grdColStyle3

..HeaderText = "Value"

..MappingName = "Value"

..Width = 75

..ReadOnly = True

End With

grdTableStyle1.GridColumnStyles.AddRange(New DataGridColumnStyle()
{grdColStyle1, grdColStyle2, grdColStyle3, grdColStyle4})

DataGrid1.TableStyles.Add(grdTableStyle1)

End Sub



Private Sub addata()

Public D As New DataTable()

D.Columns.Add("Channel")

D.Columns.Add("Name")

D.Columns.Add("Value")

R = D.NewRow

R.Item(0) = true

R.Item(1) = dchanName(e.Index + 1)

R.Item(2) = dchanState(e.Index + 1)

R.Item(3) = dchanPos(e.Index + 1)

D.Rows.Add(R)


End Sub



i know this can't work, becouse when i add the code, i generate a datatable
independent from the table i created.

but how can i add the last items, so the get places in the formated
collumns

kind regard, and sorry i keep on troubeling you with probably stupid
questions.



Maarten
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top