Solved

mutiple row types in vb.net datagridview

Posted on 2009-04-09
2
400 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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