Hi There, i created a calendar with 37 datagridviews on a form, i've put all my datagridviews in to an array collection
Public AllDatagrids As DataGridView() = {DGDays1, DGDays2, DGDays3, DGDays4, DGDays5, DGDays6, DGDays7, DGDays8, _
DGDays9, DGDays10, DGDays11, DGDays12, DGDays13, DGDays14, DGDays15, DGDays16, _
DGDays17, DGDays18, DGDays19, DGDays20, DGDays21, DGDays22, DGDays23, DGDays24, _
DGDays25, DGDays26, DGDays27, DGDays28, DGDays29, DGDays30, DGDays31, DGDays32, _
DGDays33, DGDays34, DGDays35, DGDays36, DGDays37}
which makes it easier to control which datagridviews are visible or not depending on the user selection on the month they select from a combo box.
Now when a user clicks on a row in any datagridview it opens up another form and displays additional information in a breakdown sort of way.
All my code is working fine except that it is way too long and i would like to shorten it, because i have now got duplicated code in my project.
Each datagridview has a double click event so i have 37 of these
Private Sub DGDays1_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGDays1.CellContentDoubleClick
With DGDays1
If .SelectedRows.Count <> 0 Then
Dim row As DataGridViewRow = .SelectedRows(0)
GetdataAndFillDetailsForm(row.Cells(3).Value, row.Cells(5).Value)
End If
End With
End Sub
i have created an event handler to manage the double click event of all the datagridviews which resides in my main form load event
For Each DataGridView In Modall.AllDatagrids
AddHandler DataGridView.CellContentDoubleClick, AddressOf DGArrayClick
Next
Which in turn after the user double clicks a cell on any of the datagridview it runs this code
Private Sub DGArrayClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
End Sub
so i've been trying to figure out how to get a value of the row selection from the double click event of the datagrid and i have a code block
i want to try and run something like this inside my DGArrayClick sub
GetdataAndFillDetailsForm(row.Cells(3).Value, row.Cells(5).Value)
is it possible and if so, could anyone give me a direction on how to go about it please?
It looks like you're new here. If you want to get involved, click one of these buttons!