Solved

mutiple row types in vb.net datagridview

Posted on 2009-04-09
2
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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