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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:00:23+00:00 2026-06-14T18:00:23+00:00

when I want to store/pass a value, I always use the .Tag property. for

  • 0

when I want to store/pass a value, I always use the .Tag property. for example, when I store the value:

Form prosesEdit = new FormProsesChemicalRawWbEdit();
                        prosesEdit.Tag = (int)this.proses_chemicalDataGridView.Rows[e.RowIndex].Cells[1].Value;
                        prosesEdit.ShowDialog();

Then, I would pass the value into my EDIT form like this:

proses_chemical_id = (int) this.Tag;
            this.proses_chemicalTableAdapter.FillByChemId(this.mcd_softwareDataSet.proses_chemical, proses_chemical_id);
            this.proses_chemical_listTableAdapter.FillByChemId(this.mcd_softwareDataSet.proses_chemical_list, proses_chemical_id);

but recently, I was supposed to store & pass 2 different values. let’s say (int)this.proses_chemicalDataGridView1.Rows[e.RowIndex].Cells[1].Value; and (int)this.proses_chemicalDataGridView2.Rows[e.RowIndex].Cells[1].Value;
how exactly do I do that?
Thanks

  • 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-14T18:00:24+00:00Added an answer on June 14, 2026 at 6:00 pm

    Both of the answers given so far will work but I want to elaborate on the answers a little and provide an alternative. Let’s say you create your own class like this:

    public class YourClass
    {
        public int ProsesChemicalId1 { get; set; }
        public int ProsesChemicalId2 { get; set; }
    }
    

    Then you can assign an instance of your class to the Tag property like this:

    YourClass yourClass = new YourClass();
    yourClass.ProsesChemicalId1 = this.proses_chemicalDataGridView1.Rows[e.RowIndex].Cells[1].Value;
    yourClass.ProsesChemicalId2 = this.proses_chemicalDataGridView2.Rows[e.RowIndex].Cells[1].Value;
    
    Form prosesEdit = new FormProsesChemicalRawWbEdit();
    prosesEdit.Tag = yourClass;
    prosesEdit.ShowDialog();
    

    And you can get the instance of the class back out of the Tag property like this:

    yourClass = (YourClass) this.Tag;
    this.proses_chemicalTableAdapter.FillByChemId(this.mcd_softwareDataSet.proses_chemical, yourClass.ProsesChemicalId1);
    

    However, it’s generally bad practice to use the Tag property to pass values around in forms because it requires a lot of type casting and knowledge of what is stored in each tag.

    A more robust way is to use constructor injection since you know the type of form you are creating:

    int value1 = this.proses_chemicalDataGridView1.Rows[e.RowIndex].Cells[1].Value;
    int value2 = this.proses_chemicalDataGridView2.Rows[e.RowIndex].Cells[1].Value;
    
    Form prosesEdit = new FormProsesChemicalRawWbEdit(value1, value2);  
    prosesEdit.ShowDialog();
    

    You would then most likely have to store those values as properties or fields inside the form. The reason this is a more robust approach is that it’s resistant to accidental change. In other words, if you need to pass in a 3rd value in future it’s less likely you’ll forget to change code that needs changing.

    You could also use property injection here but I’m not sure of your requirements so I’ll leave it to you to decide.

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

Sidebar

Related Questions

I want to store integer value in label and to pass to another form.
I am using https://github.com/aehlke/tag-it fot tagging now i want to pass those value(tags) to
I am a new developer on Android and I want store user data in
I want to store 2 variables in a value, but I not sure with
I want to pass the string value which I get from the textarea into
I want to store some info (key value pair) in a c# thread context
I am creating a stored procedure to which I want to pass as variable
I want to store an image in my SQLITE db. I checked out the
I want to store the password used for signing in a financial application that
I want to store a user setting(language). so i can get the corresponding resources

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.