Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:37:02+00:00 2026-06-15T16:37:02+00:00

I have multiple runtime generated datagridview controls and I would like to be able

  • 0

I have multiple runtime generated datagridview controls and I would like to be able to see if the user has selected multiple rows in a specific datagridview. For some reason, the result of the following is always zero. When I F9 stop the program, I can see that the selected value of this datagridview row is false. Any ideas how to fix this?

My code is as follows:

strDGVName = "dgvCheckpoint" & intTimeModificationSender

For Each tbp As TabPage In frmTimingP2P.tabctrlTimingTable.Controls
    For Each dgv In tbp.Controls
        If dgv.Name = strDGVName Then
            intSelectedRowCount = dgv.Rows.GetRowCount(DataGridViewElementStates.Selected)
        End If
    Next
Next

Thanks

I have now tried the following:

For Each tbp As TabPage In frmTimingP2P.tabctrlTimingTable.Controls
    For Each ctrl As Control In tbp.Controls
        Dim dgv As DataGridView = TryCast(ctrl, DataGridView)
        If Not dgv Is Nothing Then
            If dgv.Name = strDGVName Then
                intSelectedRowCount = dgv.SelectedRows.Count
            End If
        End If
    Next
Next

As well as:

Dim c As Collections.Generic.IEnumerable(Of DataGridView)
For p = 0 To frmTimingP2P.tabctrlTimingTable.TabCount - 1
    c = frmTimingP2P.tabctrlTimingTable.TabPages(p).Controls.OfType(Of DataGridView)()
    If c(0).Name = strDGVName Then p = frmTimingP2P.tabctrlTimingTable.TabCount
    End If
Next
intSelectedRowCount = c(0).SelectedRows.Count

But it still returns a zero row count.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:37:03+00:00Added an answer on June 15, 2026 at 4:37 pm

    Ok, so the solution is as follows:

    Both:

    For Each tbp As TabPage In frmTimingP2P.tabctrlTimingTable.Controls
        For Each ctrl As Control In tbp.Controls
            Dim dgv As DataGridView = TryCast(ctrl, DataGridView)
            If Not dgv Is Nothing Then
                If dgv.Name = strDGVName Then
                    intSelectedRowCount = dgv.SelectedRows.Count
                End If
            End If
        Next
    Next
    

    And:

    Dim c As Collections.Generic.IEnumerable(Of DataGridView)
    For p = 0 To frmTimingP2P.tabctrlTimingTable.TabCount - 1
        c = frmTimingP2P.tabctrlTimingTable.TabPages(p).Controls.OfType(Of DataGridView)()
        If c(0).Name = strDGVName Then p = frmTimingP2P.tabctrlTimingTable.TabCount
    Next
    intSelectedRowCount = c(0).SelectedRows.Count
    

    Work as they should. The problem was that in my runtime generated DataGridView controls, I did not set the SelectionMode Method to FullRowSelect, and I was selecting individual cells, which do not count as “Rows”.

    Thanks for your help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application is allowed to have multiple instances running and I would like to
I have a multiple user/location RCP application that currently utilizes several user configurable options.
I have multiple figures open, and I want to update them independently during runtime.
I'd like to do some stuffs before main function. I have multiple source files.
I have a requirement i.e. one view should have multiple instances at runtime for
I would like to have a solution in xml or a keyword for what
I have multiple ajax requests with javascript code as response, and I need to
I have multiple projects which are to be hosted together in a Tomcat container,
I have multiple UpdatePanels on a webpage, one inside UserControl (Purple ColorBox as show
I have multiple forms for lots of products on my page and want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.