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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:09:05+00:00 2026-05-22T01:09:05+00:00

I am pretty new in Visual Basic. I have a tab control in my

  • 0

I am pretty new in Visual Basic. I have a tab control in my form and inside it I put a listview. What I wanted to do is populate the listview everytime I clicked on each tab. But I don’t know how to do it.

Can anyone please help me?

Here is the bit of my code

Public Class Form2

    Private Sub PopulateRecords()
        Dim TSR As New ADODB.Recordset
        Dim STRSQL As String = ""
        STRSQL &= "SELECT * from Records " & vbCrLf
        STRSQL &= "WHERE (Customer_name like '" & TextBox1.Text & "%' or Item_name like '%" & TextBox1.Text & "%' or Item_code like '%" & TextBox1.Text & "%' or Price like '%" & TextBox1.Text & "%' or Qty like '%" & TextBox1.Text & "%' or Total_price like '%" & TextBox1.Text & "%' or Date_started like '%" & TextBox1.Text & "%' or Date_finish like '%" & TextBox1.Text & "%')" & vbCrLf
        STRSQL &= "order by Customer_name, Item_name" & vbCrLf
        TSR.Open(STRSQL, CNN, 1, 3)
        ListView1.Items.Clear()
        While Not TSR.EOF
            ListView1.Items.Add(TSR.Fields("Customer_name").Value)
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TSR.Fields("Item_name").Value)
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TSR.Fields("Item_code").Value)
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TSR.Fields("Price").Value)
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TSR.Fields("Qty").Value)
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TSR.Fields("Total_price").Value)
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TSR.Fields("Date_started").Value)
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TSR.Fields("Date_finish").Value)
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(TSR.Fields("ID").Value)
            TSR.MoveNext()
        End While
        TSR.Close()
    End Sub

    Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
        Call PopulateRecords()
    End Sub


End Class
  • 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-22T01:09:06+00:00Added an answer on May 22, 2026 at 1:09 am

    You should try responding to the SelectedIndexChanged event on the parent (the TabControl). This is fired when the user moves between tabs. TabPage.Click is fired when the page itself is clicked upon – not when the tab is changed to.

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

Sidebar

Related Questions

So I'm pretty new to Visual Basic and inherited this VB6 code that i
I am pretty new to php, but I am learning! I have a simple
I'm pretty new to regular expressions. I have a requirement to replace spaces in
I'm pretty much new to Objective C but I've had some experience in Visual
im pretty new at Ant and have been looking for alot of examples. I
Im pretty new to Haskell. I have a datatype: data Sentence= Prop Int |
I'm pretty new to Python and, in writing an app, have ended up with
I'm pretty new to my company (2 weeks) and we're starting a new platform
I'm a pretty new C# and .NET developer. I recently created an MMC snapin
I'm pretty new to the idea of recursion and this is actually my first

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.