Getting error adding an extra header to datagrid

A

AMD Desktop

Hi,

I need to add a header to a datagrid.


This is the code I am trying to use:

Dim dgStaffingReport As New DataGrid
Dim dgitem As New DataGridItem(0, 0, ListItemType.Header)
Dim mycell As New TableCell()

mycell.ColumnSpan = 2
mycell.Text = "Staff"
dgitem.Cells.Add(mycell)
dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)

And this is the error I am getting (index of the AddAt method, pretty
standard...):


Exception Details: System.ArgumentOutOfRangeException: Specified argument
was out of the range of valid values. Parameter name: index

Source Error:

Line 175: mycell.Text = "This Is the top level header item spanning two
columns!"
Line 176: dgitem.Cells.Add(mycell)
Line 177: dgStaffingReport.Controls(0).Controls.AddAt(0, dgitem)
Line 178:
Line 179:



Any idea why. Can anyone help?

Thank you
 
A

AMD Desktop

Is there any way to add a header? I can not use this method because this
datagrid is not for display, I export it into excel.

:-(
 
S

Steve C. Orr [MVP, MCSD]

The datagrid does not support it.
You might look into using the table control instead. It doesn't have as
much functionality, but it also doesn't have as many limitations.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top