Changing Headers on DataGrid

G

Gary

I have not had my previous posts answered and I really
need to fix this problem. Please help.

I have populated a datagrid in code but I would like to
change the header text and width of two of the columns.

I used the following code after binding the dataset to
the grid:

Dim cstStartTime As New DataGridTextBoxColumn
cstStartTime.MappingName = "StartTime"
cstStartTime.HeaderText = "Start Time"
cstStartTime.Width = 1550

I did this twice. Then I added the GridColumnStyles and
finally did a TableStyles.Add.

When the grid displays the data, no columns appear. What
am I doing wrong?

Thanks,

Gary
 
M

Michael Tkachev

DataGrid.Columns[0].HeaderText = "bla-bla";
DataGrid.Columns[0].ItemStyle.Width = 1500;

Remember! You have to do it before databind of datagrid.
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top