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 9196289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:49:06+00:00 2026-06-17T21:49:06+00:00

I have an application written in VB.NET that reads data from a file and

  • 0

I have an application written in VB.NET that reads data from a file and displays the data on the screen.

Depending on the data in the file, the program has a TabControl with up to 3 tabs and each tab in turn has a DataGridView for displaying data. For example I have a TabControl that has a tab called “Saturday” and a tab called “Sunday”.

The problem I am having is that when I read data from a file, the program displays all the data on the Saturday’s tab grid because I am not sure how to reference the Grid on the Sunday tab.

To add the DataGridView I am using the following code:

Grid = New DataGridView
Grid.Dock = DockStyle.Fill
Grid.Name = "Grid" & TabControl.SelectedIndex
Grid.Tag = "Grid" & TabControl.SelectedIndex 

And this is how I am reading the data in:

If reader.GetAttribute("controltype") = "Tab" Then
    SelectedTab = reader.Name
End If

If reader.Name = "cell" Then
y = y + 1
Grid.Rows(i).Cells(y).Style.BackColor = Color.FromName(reader.ReadElementString("cell"))
End If

What I almost want to do is something like (pseudocode):

SelectedTab.Grid.Rows(i).Cells(y).Style.BackColor = Color.FromName(reader.ReadElementString("cell"))

However when I use the above code it complains:

‘Grid’ is not a member of ‘String’

I hope you understand the issue. Let me know if you need clarification

  • 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-17T21:49:07+00:00Added an answer on June 17, 2026 at 9:49 pm

    Your code is a little unclear. However, it appears to me that the following line:

    If reader.GetAttribute("controltype") = "Tab" Then
        SelectedTab = reader.Name
    End If
    

    is creating at least one problem. It looks like you are attempting to refer to a Tabpage control by the string representation of its name, but unless I missed something, what that line is actually doing is trying to make a tabpage control type(“SelectedTab”) refer to a string type. If that is the case, then you will want to try this instead:

    If reader.GetAttribute("controltype") = "Tab" Then
        TabControl1.SelectedTab = TabControl1.TabPages(reader.name)
    End If
    

    It is a little hard to tell from the code you have posted, but that might get you headed down the right path.

    ++++++++++++

    UPDATE: It appears from your code that you are naming each DGV control by appending the index of the tab on which it is located to the string “grid.” I am going to assume that you are using a class member variable named “SelectedTab” to represent the current tab selected in the control. I will assume that at the top of your class you have done something like this:

    'Form-or-class scoped memebr variables:
    Private SelectedTab As TabPage
    Private SelectedGrid As DataGridView
    

    You should be able to refer to the active grid control using something like this:

    Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
    
        ' Set SelectedTab member variable to refer to the new selected tab page:
        SelectedTab = TabControl1.SelectedTab
    
        ' Set the SelectedGrid to refer to the grid control hosted on the selected tab page:
        SelectedGrid = TabControl1.SelectedTab.Controls("Grid" & TabControl1.SelectedIndex.ToString())
    End Sub
    

    From here, you should be able to use the member variable for SelectedGrid to refer to the grid present on which ever tab page is selected in your tab control.

    It is challenging to address your concerns with only fragments of your code. If you have additional difficulties, please post more of your code, so we can better see what else is going on.

    Hope that helps!

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

Sidebar

Related Questions

I have a simple application written in C# and .Net 2.0 that displays several
We have an application written in both C++ and .NET that installs for all
I have an application that was written in vanilla ASP.NET that I would like
I have a WinForms application written in C# for .NET 3.5 that needs to
I have this code in my ASP.NET application written in C# that is trying
I have to support an application that was written in .NET 1.1 many years
I have a .net MDI application written in vb.net. I'm trying to program a
Assume that we have a network deployed desktop application written in .NET. We don't
I have written a .net winforms application that does some heavy processing and slows
I have written a click-once deployed application in .Net that runs on windows machines.

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.