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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:05:32+00:00 2026-06-14T12:05:32+00:00

I got a main button function, where i parse the textbox text values, then

  • 0

I got a main button function, where i parse the textbox text values, then I pass those values to an another method.
After performing the first calculation, then i want to pass those parameters to another button function.

I want to assign int valueOF1, int valueOF2to this method public void testfunction(object sender, EventArgs ea) from the main button.

How can i do this?? Thank you for your help.

This is the code:

private void b_calculate_Click(object sender, EventArgs e)
    {

        int valueOF1;
        int.TryParse(t_Offset1.Text, NumberStyles.Any,
                     CultureInfo.InvariantCulture.NumberFormat, out valueOF1);

        int valueOF2;
        int.TryParse(t_Offset2.Text, NumberStyles.Any,
                     CultureInfo.InvariantCulture.NumberFormat, out valueOF2);

        int pRows = PrimaryRadGridView.Rows.Count;
        int sRows = SecondaryRadGridView.Rows.Count;

        if (pRows == 1 && sRows == 1)
        {
            calculatePS(valueOF1, valueOF2);
        }


}

private void calculatePS(int valueOF1, int valueOF2)
{
    MessageBox.Show("You are using : P-S");
    // Do some calculation & go to the next function ///
    Button2.Enabled = true;
    Button2.Click += testfunction; // Here i want to pass the valueOF1 & valueOF2

}

public void testfunction(object sender, EventArgs ea)
{
    MessageBox.Show("you...!");
    Button2.Enabled = false;
}
  • 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-14T12:05:33+00:00Added an answer on June 14, 2026 at 12:05 pm

    You can declare valueOF1 and valueOF2 as class fields, so you can access them from different methods.

    Here’s how the code could look like:

    int valueOF1 = 0;
    int valueOF2 = 0;
    
    private void b_calculate_Click(object sender, EventArgs e)
    {
        int.TryParse(t_Offset1.Text, NumberStyles.Any,
                     CultureInfo.InvariantCulture.NumberFormat, out valueOF1);
    
        int.TryParse(t_Offset2.Text, NumberStyles.Any,
                     CultureInfo.InvariantCulture.NumberFormat, out valueOF2);
    
        int pRows = PrimaryRadGridView.Rows.Count;
        int sRows = SecondaryRadGridView.Rows.Count;
    
        if (pRows == 1 && sRows == 1)
        {
            calculatePS();
        }
    }
    
    private void calculatePS()
    {
        // ** you can use valueOF1 and valueOF2 here **
    
        MessageBox.Show("You are using : P-S");
        // Do some calculation & go to the next function ///
        Button2.Enabled = true;
    
        //probably no need to register the Button2.Click event handler
        //except when the form is created
        //
        //Button2.Click += testfunction; 
    }
    
    public void testfunction(object sender, EventArgs ea)
    {
        // ** you can use valueOF1 and valueOF2 here as well **
    
        MessageBox.Show("you...!");
        Button2.Enabled = false;
    }
    

    Additional Note: int.TryParse returns a bool value that tells you whether the parse succeeded. In case the return is false, you may want to handle the parse error somehow instead of continuing with the normal flow.

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

Sidebar

Related Questions

I've got a Activty which is displayed after a info-button is pressed. Now I
Say I got two functions that looks like this: function main(Index) { doStuff(); }
I've got a custom BaseAdapter and an add button in the main activity. The
I've got main folder: c:\test And there I have 2 folders: Movies and Photos.
Can't understand what is a problem here: I have got main.cpp file where I
I got one main search field always visible at the site and a login
I've got a main project where module A depends on a a .jar file
I've got my main form Form1 running the main bulk of my program. I
I've got a main menu and a game which loads as a separate swf
In Unix, I have got three main files. One of them is a library

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.