How to use DataGrid ?

  • Thread starter Thread starter Marty
  • Start date Start date
M

Marty

Hi,

How do I set rows/colums, titles and data in the DataGrid control of
VB.NET. I don't want to pass through a dataset and use databinding. I
want to set this grid manually.

Is there any tutorial for that?

Thanks

Marty
 
Well Marty,
You can use the Tablestyle Collections for the Same. Here when you click the
datagrid and see its properties there you set the Tablestyle properties.

Or you can also use it in code like the code example listed below

Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = "Grouping"

Dim column As New DataGridTextBoxColumn
column.MappingName = "Group_Code"
column.HeaderText = "Code"
column.Width = 70
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "Description"
column.HeaderText = "Description"
column.Width = 200
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "Remarks"
column.HeaderText = "Remarks"
column.Width = 100
tableStyle.GridColumnStyles.Add(column)

Me.DataGrid1.TableStyles.Add(tableStyle)
 
Great, thanks you.



Arun said:
Well Marty,
You can use the Tablestyle Collections for the Same. Here when you click the
datagrid and see its properties there you set the Tablestyle properties.

Or you can also use it in code like the code example listed below

Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = "Grouping"

Dim column As New DataGridTextBoxColumn
column.MappingName = "Group_Code"
column.HeaderText = "Code"
column.Width = 70
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "Description"
column.HeaderText = "Description"
column.Width = 200
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "Remarks"
column.HeaderText = "Remarks"
column.Width = 100
tableStyle.GridColumnStyles.Add(column)

Me.DataGrid1.TableStyles.Add(tableStyle)

:
 
Marty,
How do I set rows/colums, titles and data in the DataGrid control of
VB.NET. I don't want to pass through a dataset and use databinding. I
want to set this grid manually.

You cannot, that is why the name is DataGrid and not Grid, it needs an
underlaying datasource.

(Which has not to be a table from a database by the way)

I hope this gives an idea?

Cor
 
Back
Top