Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Datagridview - Merge row

Posted on 2006-11-08
5
Medium Priority
?
2,789 Views
Last Modified: 2008-02-07
I have a set of data like below:

ItemNo   Month               SalesAmount
1            11                    1000
1            10                    2000
1            09                    3000
2            11                    4000
2            10                    5000
3            11                    6000


Is there any method  in datagridview to display like below:

ItemNo   Month               SalesAmount
1            11                    1000
              10                    2000
              09                    3000
2            11                    4000
              10                    5000
3            11                    6000

Hope I don't have to manipulate records one by one that not what I want!!!

Thanks a lot.

0
Comment
Question by:tora111
[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
5 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 1000 total points
ID: 17905120
I don't think this is possible, at least on the sort of simple approach you are looking for.  

What you need to remember is that a DataGridView is a mechanism for displaying and editing data which is in fact held elsewhere - in the datatable (or whatever) that is its .DataSource.  Each row in the DataGridView represents a record in the datasource.  If a record includes a value in a particular field that value will be shown in the corresponding column in the DataGridView.  Although you can choose to display, or not to display, or to re-order the display of, particular fields/columns the facility to do this is column based: that is, it applies to all rows.  So, without some (fairly complex, I think) self-coding, your ItemNo will either display or it won't display.

I'll be happy to be told I'm wrong on this: it looks like a fairly useful facility.  But, as I say, I don't think it exists in the control as it stands.

Roger
0
 
LVL 3

Assisted Solution

by:vsvb
vsvb earned 1000 total points
ID: 17906119
This is not elegent solution but as so far DataGrid not provide such utility
we have to write some custom code

        Dim d As Integer
        Dim kd As Integer
        kd = -1
        Dim cell As DataGridViewCell
        For d = 0 To DataGridView1.Rows.Count - 1
            If kd <> DataGridView1.Rows(d).Cells(0).Value Then  
                kd = DataGridView1.Rows(d).Cells(0).Value
            Else
                cell = DataGridView1.Rows(d).Cells(0)
                cell.Style.ForeColor = Color.White
                cell.ReadOnly = True
            End If
        Next

you have to write some code when cell is select .. then it shows item in selected cell ( DarkBlue/ white)
-vsvb
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

609 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