Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change name and width colums on DataGrid

Status
Not open for further replies.

mi1306

Technical User
Jul 14, 2004
44
0
0
BG
I want will change name and width colums on DataGrid. Has written the following code all on rules.
Works up to a point 1, but does not want will change columns
Ani ideas?

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

dt.Columns.Add(New DataColumn("Col0", GetType(Integer)))
dt.Columns.Add(New DataColumn("Col1", GetType(String)))
dt.Columns.Add(New DataColumn("Col2", GetType(Double)))

Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Name" & i.ToString
dr(2) = 10 * i
dt.Rows.Add(dr)
Next i

DataGrid1.DataSource = dv
1.
Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = "Artikuli"

Dim discontinuedCol As New DataGridBoolColumn
discontinuedCol.MappingName = "Check"
discontinuedCol.HeaderText = ""
discontinuedCol.Width = 50
discontinuedCol.AllowNull = False
tableStyle.GridColumnStyles.Add(discontinuedCol)

Dim column As New DataGridTextBoxColumn

column.MappingName = "ID"
column.HeaderText = "ID"
column.Width = 100
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "Name"
column.HeaderText = "Name"
column.Width = 1000
tableStyle.GridColumnStyles.Add(column)

column = New DataGridTextBoxColumn
column.MappingName = "Price"
column.HeaderText = "Price"
column.Width = 300
tableStyle.GridColumnStyles.Add(column)

DataGrid1.TableStyles.Add(tableStyle)

End Sub


Miho
 
take a look at thread796-1029632

You look to have most things correct, but are probably missing the table mapping name.


Sweep
...if it works dont mess with it
 
Hello

If column width is your problem, you have to set your datagrid column width BEFORE you set your data mappings.

Thanks
Dave
 
I think this are not the reasons.
I have an example with the same source code that works, but when i put it in my project it does not work from 1. till the end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top