none
Multiple of a control with filters RRS feed

  • Question

  • Hi

    Before i dig in to try something that probably wont work, i thought i would as quickly to see if its possible and worth investing the time.

    I need to make a single form in my application that has 6 identical grid controls. All controls will collect data from the same table but will be filtered based on stageID. What i didnt want to was to add them all static because the rows in each control can vary depending on the current job status & progress. So i was wondering if there was a way to add the grid controls to a form / panel that allows me to place the controls showing all rows with the next controls underneath? Then the panel would allow me to scroll all of the grids without scrolling the grids themselves.

    So basically, each grid gets placed / populated to show all rows with data, then the next grid is placed underneath also showing all rows etc and for me to view all controls, i only need to scroll the panel.

    I am currently adding all 6 grid controls with static heights and scrolling them individually but i need to be able to all rows at a glance.

    Hope that all makes sense...

    Nacho :)


    Nacho is the derivative of Nigel - True fact! I am self taught in VB.Net. 50% of the time, I am right 100% of the time!

    Saturday, September 1, 2018 8:10 PM

All replies

  • Hi

    If I understand your question correctly, I think you are wanting to define a new DataGridView, Add Columns and add an indeterminate number of rows to it, resize it such that all rows are visible (without scrolling), then repeat that process for a total of 6 DataGridViews all added one below the other.

    Is that something close to what you want?


    Regards Les, Livingston, Scotland

    Saturday, September 1, 2018 8:52 PM
  • Hi

    Yes. Somehow your description of what im trying to achieve is actually way better and more efficient that mine :)


    Nacho is the derivative of Nigel - True fact! I am self taught in VB.Net. 50% of the time, I am right 100% of the time!

    Saturday, September 1, 2018 8:57 PM
  • Hi

    Here is some code to try out and see if it does what you want. Of course, I have just generated dummy data, so that side of it should be ignored. What it is supposed to do is to generate 6 DataGridViews each with random row numbers and stack them so that you can scroll through all DGV (all rows).

    Try this out as a stand alone example and see if it helps. Just needs a Blank default Form1.

    ' Blank Form1 
    Option Strict On
    Option Explicit On
    Public Class Form1
      Dim rand As New Random
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim gap As Integer = 0
        For i As Integer = 0 To 5
          Dim dgv As New DataGridView
          With dgv
            .Location = New Point(8, 8 + gap)
            .Name = "dgv" & i.ToString
            .ColumnCount = 4
            For j As Integer = 0 To rand.Next(4, 12)
              .Rows.Add(j, j * 2, j * 3, j * 4)
              gap += dgv.Rows(0).Height
            Next
            .Anchor = AnchorStyles.Left Or AnchorStyles.Top
            .Size = New Size(400, 26 + dgv.RowCount * 24)
          End With
          Controls.Add(dgv)
          gap = 8 + dgv.Bottom
        Next
      End Sub
    End Class
    


    Regards Les, Livingston, Scotland

    Saturday, September 1, 2018 9:13 PM