Solved

Datagridview - Merge row

Posted on 2006-11-08
5
2,787 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 250 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 250 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

729 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