Solved

mutiple row types in vb.net datagridview

Posted on 2009-04-09
2
393 Views
Last Modified: 2013-11-26
Hi,
Is it possible to have 2 types of rows in a datagridview.
e.g. an orderheader with orderdetails
rowtype1   order  customername    date
rowtype2   article# article name     price  number ordered
rowtype2   article# article name     price  number ordered
rowtype2  article# article name      price  number ordered  
rowtype1  order  customername    date
rowtype2   article# article name     price  number ordered
rowtype2   article# article name     price  number ordered
as you can see rowtype1 has an other number of columns as rowtype2
thnx
Rob
0
Comment
Question by:dgb
2 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 250 total points
Comment Utility
You can't do that as the each column in the DataGridView has a DataPropertyName which tells the column where it should get it's data to display.
In your example your two different row types have different names (and different data types from the looks of it), so the columns would have some issues knowing which column mapping to use.

You could create a dataable with the total number of columns required, all with a datatype of object. You could then populate the table with whatever data you need on a per-row basis. There would be two issues with this however:
  1. You lose any type safety if you're using the grid to edit the data displayed
  2. You won't be able to do any custom formatting on the columns: How would the 3rd column know to format a value as a DateTime or Decimal?
If you're just displaying data (ie. the grid is readonly), you could create a table only containing string values, and then as you populate it, format each value the way you desire. I've done this to display a bank statement type display.

If you're wanting to edit the data, I'd recommend going with two grids, the top one showing the Order Number, Customer Name & Date. The lower one is refreshed when selecting a different order, and shows Article info, Price & Quantity
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 250 total points
Comment Utility
That looks like a perfect opportunity to use the banding technology with the Infragistics UltraWinGrid/UltraWebGrid...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now