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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:17:45+00:00 2026-05-31T11:17:45+00:00

I am using 3 unbound DataGridView controls to display certain information. To load the

  • 0

I am using 3 unbound DataGridView controls to display certain information. To load the information into those DGVs, I am pulling the information from an encrypted file, decrypting it, parsing the information, then trying to fill the DGVs with that information. The loading from the file is called by the menu item click. Here is what I have so far:

Private Sub miCLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 
    Handles miCLoad.Click
    Dim FilePath As String = "C:\FList\CList.clt"
    Dim LoadFile As New SaveandLoad.SaveAndLoad
    Dim FileRead As New Simple3Des("MyPassword")
    Dim FileString As String = FileRead.ReadFile(FilePath)


    With LoadFile
        .WhichList = dgCourses
        .FilePath = FilePath
        .DecryptedString = FileRead.DecryptData(FileString)
        .dgList = dgCourses
    End With

    Call LoadFile.LoadFile()
End Sub

Public Class SaveandLoad
Public Property WhichList As New DataGridView
Public Property FilePath As String
Public Property DecryptedString As String
Public Property EncryptedString As String
Public Property dgList As Control

Public Sub LoadFile()

    Dim dgRow As DataGridViewRow
    Dim dgCell As DataGridViewTextBoxCell
    Dim Lines() As String = DecryptedString.Split(vbLf)
    Dim LinesList As List(Of String) = Lines.ToList
    LinesList.RemoveAt(Lines.Length - 1)

    For Each Line As String In LinesList
        Dim Fields() As String = Line.Split(",")
        dgRow = New DataGridViewRow

        For x = 0 To (WhichList.Columns.Count - 1) Step 1
            dgCell = New DataGridViewTextBoxCell
            dgCell.Value = Fields(x).ToString
            dgRow.Cells.Add(dgCell)
        Next
        WhichList.Rows.Add(dgRow)
    Next

    Select Case WhichList.Name
        Case "dgCourses"
            frmFacultyList.dgCourses = WhichList
            frmFacultyList.dgCourses.Refresh()
            WhichList.Dispose()
        Case "dgFList"
            frmFacultyList.dgFList = WhichList
            frmFacultyList.dgFList.Refresh()
            WhichList.Dispose()
        Case "dgSList"
            frmFacultyList.dgSList = WhichList
            frmFacultyList.dgSList.Refresh()
            WhichList.Dispose()
    End Select

    MsgBox("List Successfully Loaded", vbOKOnly, "Load")

End Sub

I want to be able to reference (or fill) a DGV without using ‘select case’ or ‘if-then’ statements. This will be too inefficient once I start adding the many other DGVs, that will be added in the future. Therefore, the title is the main question. I am using VS Express 2010.

  • 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-05-31T11:17:47+00:00Added an answer on May 31, 2026 at 11:17 am

    Here is what worked for me in VB.NET:

    Dim FormControls As New frmFacultyList.ControlCollection(frmFacultyList)
    
            For Each DGV As DataGridView In FormControls
                If WhichList.Name = DGV.Name Then
                    DGV = WhichList
                    DGV.Refresh()
                End If
            Next
    

    Make an instance of the control collection then search specifically for DGVs using For Each. Simple and efficient.

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

Sidebar

Related Questions

I'm using c#2.0 and WinForms. I have a datagridview control, unbound, loading small amounts
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I'm using drscheme from: http://www.archlinux.org/packages/extra/x86_64/drscheme/ I'm trying to work with the sample code in
I'm struggling to open a file, and read each line until EOF. I'm using
I am using a program from the Simply Scheme book: (require (planet dyoo/simply-scheme)) (define
I am using a Datagridview (unbounded mode) and I have selected enable adding in
I'm new to using the C#/.NET programming Language and I have created a DataGridView
I'm using an unbound data grid in Visual Basic. I made the following loop
I recently ran into major problems inserting records into a SQL Server backend from
I am trying to send sms from java application using SMPPSim as SMS gateway

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.