help(F1)(F1) datagrid column width

G

Guest

hello all
i need your help
when i try to customize the datagrid and it's column in programmaticaly way
by this code nothing happening so i need your help
to know why the gridcolumn style dosn't work as i want
her is my code
---------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim ts As New DataGridTableStyle()
Dim col1 As New DataGridTextBoxColumn()
Dim col2 As New DataGridTextBoxColumn()
Dim DT As New DataTable("custinfo")
Dim dr As DataRow
ts.MappingName = "Cust"
ts.AlternatingBackColor = Color.CornflowerBlue

col1.MappingName = "Cust ID"
col1.HeaderText = "Cust ID"
col1.NullText = ""
col1.Width = 250
ts.GridColumnStyles.Add(col1)

col2.MappingName = "Cust Name"
col2.HeaderText = "Cust Name"
col2.NullText = ""
col2.Width = 300
ts.GridColumnStyles.Add(col2)
DataGrid1.TableStyles.Add(ts)

DT.Columns.Add(New DataColumn("Col1", GetType(String)))
DT.Columns.Add(New DataColumn("col2", GetType(String)))
dr = DT.NewRow
dr.Item(0) = ""
dr.Item(1) = ""
DT.Rows.Add(dr)

Me.DataGrid1.DataSource = DT
End Su
 
C

Claes Bergefall

and Col1.MappingName = "Cust ID" to Col1.MappingName = "Col1"
and Col2.MappingName = "Cust Name" to Col2.MappingName = "col2"

/claes


Sijin Joseph said:
Change
ts.MappingName = "Cust"
to
ts.MappingName = "custinfo";
 

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