2 Replies - 4353 Views - Last Post: 04 August 2007 - 11:43 PM Rate Topic: -----

#1 cygnusX  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 159
  • Joined: 19-May 07

DataGridView rows question

Posted 04 August 2007 - 12:58 AM

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?
Is This A Good Question/Topic? 0
  • +

Replies To: DataGridView rows question

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,127
  • Joined: 18-April 07

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.
Was This Post Helpful? 0
  • +
  • -

#3 graeme bradbury  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 28-June 07

Re: DataGridView rows question

Posted 04 August 2007 - 11:43 PM

View PostcygnusX, 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1