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

Chaning Column Text In Datagrid

Status
Not open for further replies.

LobsterSte

Programmer
Joined
Sep 2, 2006
Messages
9
Location
ZA
How can I changed the text above every column in a datagrid?

I can't find anything about it in Msdn!

Please Help!
 
The default column name is set to the name coming from your DB. If you want to change it to something else then you can use the this:
Assume DataGrid name as 'dg', 'Emp_name' is default from DB, 'Employee Name' as custom name.
Code:
Dim dgTS As New DataGridTableStyle
Dim ColStyle As New DataGridTextBoxColumn
ColStyle.MappingName = "Emp_name"
ColStyle.HeaderText = "Employee Name"
dgTS.GridColumnStyles.Add(ColStyle)
dg.TableStyles.Add(dgTS)
You can do this at design time also so that you can specify all the fields as per your order.
Code:
<Columns>
<asp:BoundColumn DataField="Emp_name" HeaderText="Employee Name"></asp:BoundColumn>
</Columns>

Sharing the best from my side...

--Prashant--
 
Web.

But how do you do it in a Windows app?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top