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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid column width 1

Status
Not open for further replies.

BoFenger

Programmer
Aug 6, 2003
22
DK
Hey TT
I'am new in VB
I have a datagrid in VB.Net, that is generated with the wizard. I have a column called "user", where I want to change the width. The datagrid name is "grdm100".
I have tryed a lot without anything happening, Do I need to refresh the datagrid, nad if, how do I do that

Hope you can help me

Kind regards Bo
 
Try this....

Dim objDataGridStyle As New DataGridTableStyle()
Dim objTextCol As New DataGridTextBoxColumn()

DataGrid1.TableStyles.Clear()

'The following code formats the datagrids column header and width
'Set the MappingName for the DataGridTableStyle
objDataGridStyle.MappingName = "ReturnData"

'Set references for columns
objTextCol = New DataGridTextBoxColumn()
objTextCol.MappingName = "usrid"
objTextCol.Width = 45
objTextCol.HeaderText = "User ID"
objDataGridStyle.GridColumnStyles.Add(objTextCol)

'Add the DataGridTableStyle to the DataGrid
DataGrid1.TableStyles.Add(objDataGridStyle)


This can also be acheived through the datagrids properties window.

KJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top