Solved

mutiple row types in vb.net datagridview

Posted on 2009-04-09
2
399 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
ID: 24114861
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
ID: 24115103
That looks like a perfect opportunity to use the banding technology with the Infragistics UltraWinGrid/UltraWebGrid...
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

18 Experts available now in Live!

Get 1:1 Help Now