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

  • Home
  • SEARCH
  • 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 7697305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:58:53+00:00 2026-05-31T21:58:53+00:00

I have ListBox called lstProductGroups. On a simple Windows Form, a method called GetGroups

  • 0

I have ListBox called lstProductGroups.

On a simple Windows Form, a method called GetGroups gives me string groups selected by the user like Cars, Bikes etc.

public List<string> GetGroups()
{
    List<string> prodGroups = (from object item in lstProductGroups.SelectedItems select item.ToString()).ToList();

    return prodGroups;
}

But if I try to access same method from another thread I get all items in my list called System.Data.DataRowView.

I even tried it in a foreach loop with BeginInvoke, but the item.ToString() always returns System.Data.DataRowView.

I am new to Winforms with threading. What am I doing wrong?

  • 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-31T21:58:54+00:00Added an answer on May 31, 2026 at 9:58 pm

    First declare a delegate:

    delegate List<string> GetItemsDlg();
    

    Change your method like this:

    List<string> GetGroups() {
        if (lstProductGroups.InvokeRequired) {
            var dlg = new GetItemsDlg(GetGroups);
            return lstProductGroups.Invoke(dlg) as List<string>;
        }
        List<string> prodGroups = (from object item in lstProductGroups.SelectedItems select item.ToString()).ToList();
    
        return prodGroups;
    
    }
    

    Call your method:

    List<string> items = GetGroups();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this method Verify_X which is called during databind for a listbox selected
I have a checkBox in my Windows application called Continuous. When user checks this
net to make a Windows Phone application. I have a listBox on page1 called
Let's say I have a ListBox called animalList . As DataSource I use following
I use Visual studio 2008 I have 5 listbox's on form,I created a new
I'm sure this is simple but it's driving me nuts. I have a ListBox
I have an object called 'SelectedDay' I instantiate it like this: Day SelectedDay =
I have added an object called fixture to a listbox. I look in a
Below is the complete code for the example. I have a user control called
i have ListBox on my xaml page called MainListBox. i can get index that

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.