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

Datagrid changing column headings

Status
Not open for further replies.

1todd1

Programmer
Jan 19, 2002
17
NZ
There must be an easyer way to change the column headings of a datagrid control than going through the columns collection

Has anyone any ideas please )

Dim f As Column

For Each f In DataGridPeople.Columns
Select Case f.Caption
Case "FirstName"
f.Caption = "First Name"
Case "LastName"
f.Caption = "Last Name"
end select
next i


Thanks for your thoughts and comments :)

Todd
 
Because a datagrid, as opposed to say a FlexGrid, is actually a collection of columns, you need to set each column header seperately. Once set, you can prevent the column header names from reverting back to the field names during a requery by using the HoldFields and Rebind methods.
You could also set the grid header to the field's Description property (Set in the database) using the DDL from ADOX.

Or, you could create an array of caption text for each grid, and loop through each column and using the column index to match up with the array index.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top