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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:46:18+00:00 2026-05-22T20:46:18+00:00

I created an object in on event, now I want another event to access

  • 0

I created an object in on event, now I want another event to access it. How do I do this?

I’m doing this in Visual Studio 2010.

I have a form that has three button events. The first button creates an object. I want the second button to use the object. How do I do this?

   public void buttonCreate_Click(object sender, EventArgs e)
    {
        int size;
        int sizeI;
        string inValue;

        inValue = textBoxSize.Text;
        size = int.Parse(inValue);
        inValue = comboBoxSizeI.Text;
        sizeI = int.Parse(inValue);

        Histrograph one = new Histrograph(size, sizeI);
    }

    public void buttonAddValue_Click(object sender, EventArgs e)
    {
        int dataV = 0;
        string inValue;
        inValue = textBoxDataV.Text;
        dataV = int.Parse(inValue);
        one.AddData(dataV); //using the object
    }
  • 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-22T20:46:18+00:00Added an answer on May 22, 2026 at 8:46 pm

    If I parse your question correctly, you want to use the one variable created in buttonCreate_Click in buttonAddValue_Click.

    To accomplish this you need to make one a class variable, as in:

     class MyForm : Form
     {
        Histogram one;
    
    public void buttonCreate_Click(object sender, EventArgs e)
    {
        int size;
        int sizeI;
        string inValue;
    
        inValue = textBoxSize.Text;
        size = int.Parse(inValue);
        inValue = comboBoxSizeI.Text;
        sizeI = int.Parse(inValue);
    
        one = new Histrograph(size, sizeI);  // NOTE THE CHANGE FROM YOUR CODE
    }
    
    public void buttonAddValue_Click(object sender, EventArgs e)
    {
        int dataV = 0;
        string inValue;
        inValue = textBoxDataV.Text;
        dataV = int.Parse(inValue);
        one.AddData(dataV); //using the object
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an auto-reset event object created like this: handle = CreateEvent(NULL, true, false,
Can a custom event be created for any object method? To do this do
I've created a gridview dynamically, now i want to fire an event when the
I have a object which contains unicode data and I want to use that
I have created a strongly signed assembly in Visual Studio 2008 against the .NET
I have one complicated situation with JavaScript. I have created object. This object loads
What I am doing is creating an object(A) that holds a reference to another
I am using LINQ to access my database, and thereby gets a LINQ-created object
I created an object literal in JS, but wanna to access a property without
I have created a class that inherits the QListWidget and is meant to be

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.