Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All...
i am doing report management system in vb.net,i want to display the data in gridview the following type...

This is my MS Access Database:
______________________________________________________________________________________________
INVOICE ID | CLIENT ID | CLIENT NAME |PAYMENT DATE | TOTAL AMOUNT | BALANCE AMOUNT
______________________________________________________________________________________________
1 | 1 | RAVI | 1-1-2013 | 5000 | 3000
1 | 1 | RAVI | 2-2-2013 | 5000 | 1000
2 | 2 | KUMAR | 5-1-2013 | 10000 | 5000
3 | 3 | RAJ | 3-1-2013 | 2000 | 0
2 | 2 | KUMAR | 8-2-2013 | 10000 | 2000
4 | 1 | RAVI | 10-5-2013 | 5000 | 2000
5 | 3 | RAJ | 12-8-2013 | 8000 | 4000
-----------------------------------------------------------------------------------------------

I Want to be display this data in gridview like below:

______________________________________________________________________________________________
INVOICEID | CLIENTID | CLIENT NAME | PAYMENT DATE | TOTAL AMOUNT | BALANCE AMOUNT
______________________________________________________________________________________________
1 | 1 | RAVI | 1-1-2013 | 5000 | 3000
------------| 2-2-2013 | 5000 | 1000
4 | | 10-2-2013 | 5000 | 2000
----------------------------------------------------------------------------------------------
2 | 2 | KUMAR | 5-1-2013 | 10000 | 5000
------------ | 8-1-2013 | 10000 | 2000
----------------------------------------------------------------------------------------------
3 | 3 | RAJ | 3-1-2013 | 2000 | 0
5 --------- | 12-8-2013 | 8000 | 0
______________________________________________________________________________________________


PLS send your ideas....
Posted
Updated 26-Aug-13 23:50pm
v3
Comments
abbaspirmoradi 27-Aug-13 5:57am    
Are you want put multiple data into one feild in gridview?
TrushnaK 27-Aug-13 6:00am    
bind data to gridview which is comes by group using query....
sv sathish 27-Aug-13 6:18am    
this case i want to Group by
Invoice id,
Client id and
Client name

 
Share this answer
 
v2
Comments
sv sathish 27-Aug-13 6:25am    
Thank you for your response Sir but it's not clear for me,Because I am beginner of the coding, so pls send easy way to understandable code me Sir.
And i want vb.net code sir.
abbaspirmoradi 27-Aug-13 6:41am    
dear you must try yourself and use this links special second link that explian same problem.it is very clear.if you want progress in programming try to get it..
good luck
I am solve this problem myself, My code is below:

VB
Private Sub DataGridView1_CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
       
        If e.ColumnIndex = 2 AndAlso e.RowIndex <> -1 Then
           'e.ColumnIndex = (2) is a column index of your grouping field. 
            Using gridBrush As Brush = New SolidBrush(Me.DataGridView1.GridColor), backColorBrush As Brush = New SolidBrush(e.CellStyle.BackColor)

                Using gridLinePen As Pen = New Pen(gridBrush)

                    e.Graphics.FillRectangle(backColorBrush, e.CellBounds)
                    If e.RowIndex < DataGridView1.Rows.Count - 2 AndAlso DataGridView1.Rows(e.RowIndex + 1).Cells(e.ColumnIndex).Value.ToString() <> e.Value.ToString() Then
                        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, e.CellBounds.Bottom - 1)
                    End If
                    e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, e.CellBounds.Top, e.CellBounds.Right - 1, e.CellBounds.Bottom)
                    If Not e.Value Is Nothing Then
                        If e.RowIndex > 0 AndAlso DataGridView1.Rows(e.RowIndex - 1).Cells(e.ColumnIndex).Value.ToString() = e.Value.ToString() Then
                        Else
                            e.Graphics.DrawString(CType(e.Value, String), e.CellStyle.Font, Brushes.Black, e.CellBounds.X + 2, e.CellBounds.Y + 5, StringFormat.GenericDefault)
                        End If
                    End If
                    e.Handled = True
                End Using
            End Using
        End If
End Sub
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900