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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:45:32+00:00 2026-05-14T14:45:32+00:00

I am a C# newbie and have a class that needs to pass row

  • 0

I am a C# newbie and have a class that needs to pass row information to a grid in the windows form. What is the best way to do it? I have put in some example code for better understanding.

public class GUIController
{   
    private My_Main myWindow;


    public GUIController( My_Main window )
    {
        myWindow = window;
    }

    public void UpdateProducts( List<myProduct> newList )
    {
        object[] row = new object[3];

        foreach (myProduct product in newList)
        {
            row[0] = product.Name;
            row[1] = product.Status;
            row[2] = product.Day;

            //HOW DO I USE BeginInvoke HERE?
       }
    }
}

And the form class below:

public class My_Main : Form
{
    //HOW DO I GO ABOUT USING THIS DELEGATE?
    public delegate void ProductDelegate( string[] row );
    public static My_Main theWindow = null;

    static void Main(  )
    {            
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        theWindow = new My_Main();
        Application.Run(theWindow);

    }

    private void My_Main_Load( object sender, EventArgs e )
    {            

        /// Create GUIController and pass the window object
        gui = new GUIController( this );
     }

    public void PopulateGrid( string[] row )
    {
        ProductsGrid.Rows.Add(row);
        ProductsGrid.Update();

    }
}
  • 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-14T14:45:33+00:00Added an answer on May 14, 2026 at 2:45 pm

    Like this:

    myWindow.BeginInvoke(new My_Main.ProductDelegate(myWindow.PopulateGrid), new object[] { row });
    

    However, you should only use Invoke / BeginInvoke if your code is running on a background thread.

    If your UpdateProducts method runs on the UI thread, you don’t need BeginInvoke; you can simply call the method normally, like this:

    myWindow.PopulateGrid(row);
    

    If you do call BeginInvoke, you need to create a separate array instance in each iteration by moving the declaration of row inside the loop.

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

Sidebar

Related Questions

Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I'm a Django newbie who needs your help Have this database model: class Record(models.Model):
Okay, newbie multi-threading question: I have a Singleton class. The class has a Static
I'm brand new to SQL Server 2008, and have some newbie questions about the
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
Java Newbie here. I have a JFrame that I added to my netbeans project,
This is a pretty newbie question- please know I'm aware of that. I have
NEWBIE ALERT! background: For the first time, I am writing a model that needs
I am a newbie in grails and groovy. I have a Project domain-class with
I have an application that receives information from a database, and is used 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.