DataGridView Questions

S

stumorgan

I have a couple questions regarding the DataGridView object...

1) What is the underlying data type that the DataGridView uses if you
are using it unbound and do for instance dgv.Columns.Add(). Is there
any way to access that data type directly, since the DataSource field
is null when the DataGridView is unbound?

2) Is there any way to add a row which does not have as many columns
as the rest of the grid? Basically I have about 10 columns of data
but every so often I want to put an "event" row in the table to show
where an event happened. I pretty much just want that event row to
have 2 columns, one to say the time the event happened and another
with the description of the event. Is this possible in the
DataGridView object, or if not then is it possible in any other native
C# object that I can display in a DataGridView type fashion?

Thanks in advance,
Stu
 
M

Matthias Krug

1) What is the underlying data type that the DataGridView uses if you
are using it unbound and do for instance dgv.Columns.Add(). Is there
any way to access that data type directly, since the DataSource field
is null when the DataGridView is unbound?

I am nearly ONLY using unbound grids, but that question never came to my
mind. I usually find that if I _presume_ the underlying datatype to be
of type "string" as long as it is undefined, then I don't have problems.
but every so often I want to put an "event" row in the table to show
where an event happened. I pretty much just want that event row to
have 2 columns, one to say the time the event happened and another
with the description of the event.

Maybe a "ListView" control can even do better what you want. If you want
to stick to the DataGridView you can use the CellPaint-Events to
determine which type of row is displayed.
I never touched the borders of cells for such a purpose, but it should
be possible to make the cell-borders of neighbouring cells disappear in
the beforecellpaint event, for each row that is of type "event".
 

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

Top