C
Claudio111
Guest
Hi All
I'm started to bulid a DataGridview Grouping project (that will be very hard !!) but i will procede step by step
1) first step is to pass a DGV to a component that will modify the DGV in same way
2) second step is go back to the calling form and show the original DGV wothout Modification
The following image is the original DGV
Then when I click on "Raggruppa" I pass the DGV to a Component that in this case just changes
all the value on a Column to "TT"
What I wish now is go back to original DGV if I click again on Raggruppa Command
I'm using the following code in the callin Form
#Region "RAGGRUPPA"
Private Sub CmdRaggruppa_Click(sender As Object, e As EventArgs) Handles CmdRaggruppa.Click
Select Case FlagRaggruppa
Case False
'active Grouping
Grouper = New DGVGrouper(DGV)
FlagRaggruppa = True
GroupingLabelStatus.Visible = True
Case True
' deactive grouping
FlagRaggruppa = False
Grouper.chiudi()
DGV.DataSource = Bs1
DGV.Refresh()
Case True
End Select
End Sub
#End Region
and this is the code for the component
Imports System.ComponentModel
Imports System.Windows.Forms
Partial Public Class DGVGrouper
Inherits Component
Private WithEvents RDGV As DataGridView
Public Sub New(ByRef Grid As DataGridView)
If Grid IsNot Nothing Then
RDGV = Grid
AddHandler RDGV.RowPrePaint, (AddressOf RDGV_RowPrePaint)
RDGV.Refresh()
End If
End Sub
Private Sub RDGV_RowPrePaint(sender As Object, e As DataGridViewRowPrePaintEventArgs) Handles RDGV.RowPrePaint
RDGV.Rows(e.RowIndex).Cells(3).Value = "TT"
End Sub
Public Sub chiudi()
RemoveHandler RDGV.RowPrePaint, (AddressOf RDGV_RowPrePaint)
End Sub
End Class
But in this way the DGV does not show the original values.
Where am I wrong ?
Thanks for help
Claudio
Continue reading...
I'm started to bulid a DataGridview Grouping project (that will be very hard !!) but i will procede step by step
1) first step is to pass a DGV to a component that will modify the DGV in same way
2) second step is go back to the calling form and show the original DGV wothout Modification
The following image is the original DGV
Then when I click on "Raggruppa" I pass the DGV to a Component that in this case just changes
all the value on a Column to "TT"
What I wish now is go back to original DGV if I click again on Raggruppa Command
I'm using the following code in the callin Form
#Region "RAGGRUPPA"
Private Sub CmdRaggruppa_Click(sender As Object, e As EventArgs) Handles CmdRaggruppa.Click
Select Case FlagRaggruppa
Case False
'active Grouping
Grouper = New DGVGrouper(DGV)
FlagRaggruppa = True
GroupingLabelStatus.Visible = True
Case True
' deactive grouping
FlagRaggruppa = False
Grouper.chiudi()
DGV.DataSource = Bs1
DGV.Refresh()
Case True
End Select
End Sub
#End Region
and this is the code for the component
Imports System.ComponentModel
Imports System.Windows.Forms
Partial Public Class DGVGrouper
Inherits Component
Private WithEvents RDGV As DataGridView
Public Sub New(ByRef Grid As DataGridView)
If Grid IsNot Nothing Then
RDGV = Grid
AddHandler RDGV.RowPrePaint, (AddressOf RDGV_RowPrePaint)
RDGV.Refresh()
End If
End Sub
Private Sub RDGV_RowPrePaint(sender As Object, e As DataGridViewRowPrePaintEventArgs) Handles RDGV.RowPrePaint
RDGV.Rows(e.RowIndex).Cells(3).Value = "TT"
End Sub
Public Sub chiudi()
RemoveHandler RDGV.RowPrePaint, (AddressOf RDGV_RowPrePaint)
End Sub
End Class
But in this way the DGV does not show the original values.
Where am I wrong ?
Thanks for help
Claudio
Continue reading...