I have DataGridView with three columns.Obviosly when rows are added to the datagridview,they will be divided in 3 parts from columns borders.What i want to do is to add few rows which are not divided by the columns borders,i.e. just like when there is one column.How to achieve that?Is it possible to do that in the same DataGridView control,to have the ordinary rows divided by the borders and few rows which are not?
DataGridView rows question
Page 1 of 12 Replies - 4167 Views - Last Post: 04 August 2007 - 11:43 PM
Replies To: DataGridView rows question
#2
Re: DataGridView rows question
Posted 04 August 2007 - 12:23 PM
Not with the default datagridview control. What you are asking kind of goes against the idea of what a grid would be for. Grids are designed to give you the columns and adding each item like you would a spreadsheet. If you find yourself wanting to grid a few items and not others you should be asking yourself if perhaps the datagridview is the right control for what you are doing.
Even if you could, then you may run into problems later. The grid is designed to give you a very uniform appearance and more importantly, standard interface. Just think, if you had some items on 3 columns and others on 1 column then you would have to write extra code just to check if the item is 1 column or 3 when you iterate through it. It would get cumbersome very quickly.
I guess this is the long way to say no and you probably wouldn't want it to.
Even if you could, then you may run into problems later. The grid is designed to give you a very uniform appearance and more importantly, standard interface. Just think, if you had some items on 3 columns and others on 1 column then you would have to write extra code just to check if the item is 1 column or 3 when you iterate through it. It would get cumbersome very quickly.
I guess this is the long way to say no and you probably wouldn't want it to.
#3
Re: DataGridView rows question
Posted 04 August 2007 - 11:43 PM
cygnusX, on 4 Aug, 2007 - 12:58 AM, said:
I have DataGridView with three columns.Obviosly when rows are added to the datagridview,they will be divided in 3 parts from columns borders.What i want to do is to add few rows which are not divided by the columns borders,i.e. just like when there is one column.How to achieve that?Is it possible to do that in the same DataGridView control,to have the ordinary rows divided by the borders and few rows which are not?
Sort of.
It's possible in datagridview to have a column that spans multiple columns (counter intuitive i know)
So for your needs you would have your columns as normal with one column spanning the full width of the grid and only use that column in the rows you need it too.
This is done by handling the RowPrePaint and/or RowPostPaint events depending on your needs
MSDN Article and Example
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|