Good morning,
Generally, a datagridview is used for displaying detail data, and it sounds
like your records are the detail data - but you want to display each row sort
of wrapped around, so to speak. Here is another idea. On the primary form
you have the main datagridview. If a user needs to see the entire row in one
shot - you can programm the app so that when the user selects a row in the
main datagridview - it brings up a 2nd form. In this 2nd form is where you
have the 5 temp datagridviews.
In order to keep track of where the user is on the main datagridview, use a
CurrencyManager object. My suggestion(s) here is/are based on the notion
that you are already using a currency manager. If you are not using a
currency manager - you should note that whenever you are using a
datagrid/datagridview you should always be using a currencyManager:
declare at form Level (or globally sometimes in a Module - you can have
multiple currencyManagers)
Dim curMgr1 As CurrencyManager
Private Sub Form_Load(...) Handles Me.Load
....
curMgr1 = CType(Me.BindingContext(dataset.Tables("tbl1"), CurrencyManager)
curMgr1.Position = 0
txtRecordPosition.Text = (curMgr1.Position + 1).ToString
Datagridview1.DataSource = dataset.Tables("tbl1"0
....
End Sub
In the click event of the datagridview, the currencyManager will
automatically update its position (starting at position 0 (zero) - thus I add
a 1 when displaying the position). Make your dataset Application level
(global). On the click event of the datagridview you bring up the 2nd form.
Note: I generally display datagridview recordposition in a statusstrip
lable. Add a statusSTrip from the toolbox to your datagridview (or to the
form). It will automatically dock to the bottom of the form. When you click
on the statusStrip, it will automatically start creating either a
statusLable, or dropdown box, or textbox (very nifty control).
Private Sub dgrv1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles dgrv1.Click
tssL2.Text = (curMgr1.Position + 1).ToString
Dim frm As New Form2
frm.Show
End Sub
In Form2 you have your 5 datagrids. You populate your 5 temp tables from
dataset.Tables("tbl1"). You can pass the selected row from the main form
either to the constructor of Form2 and populate your temp tables directly
from the row or set up a ReadOnly property on your main form that would
contain the selected row and read the selected row from the property when
Form2 comes up, or you can pass in the index of the selected row and use a
Dataview control to find that row in dataset.Tables("tbl1") when in Form2 and
read the contents of the row that way, or you can use an ArrayList to collect
all the values from the selected row and pass the ArrayList to Form2 (I think
the arrayList idea would be the easiest - brain storming here). Say we go
with the ArrayList idea, read in the first 10 items from the list to
tempTable1, then the next 10 items to tempTbl2, tmptbl3, ... then
For i As Integer = 0 to ArrayList.Count
If i < 10 Then
populate tmptbl1
End If
If i >= 10 And i < 20 Then
populate tmptbl2
End If
....
Next
datagridvew1.Datasource = ds.Tables("tmpTbl1")
datagridview2.Datasource = ds.Tables("tmpTbl2")
....
Now you have a static extended dispaly of the selected row with all the
column Headers viewable on one form without having to scroll.
If this seems a little tedious, just remember -- you are the programmer.
This is what you do.
Regards,
Rich