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

The Archive Base Latest Questions

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

Here is my scenario: I have a windows form designed in Visual Studio 2010.

  • 0

Here is my scenario:

I have a windows form designed in Visual Studio 2010. The form is quite simple. It has 2 text boxes with FirstName and LastName label. And one Display Button.

I have a class name Friend. This class has a Display() method that simply display the first and lastname in a MessageBox.

Now what I am trying to do is:

I instantiate an object “f1” of class Friend at form1_load(object sender, EventArgs e) method. and On the form Display button Click event, I tried to call the Display() method of friend class using f1 object that I instantiate on Form Load event.

But it gave me the error message ” The name f1 doesn’t exist in the current context.”

Is it possible to do what I am trying to do anyway?

Thank You for your help.

  • 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:15:26+00:00Added an answer on May 22, 2026 at 8:15 pm

    Just make it a member variable rather than local:

    public class MyForm : Form 
    {
         Friend f1;
    
        private void OnLoad()
        {
           f1 = new Friend();
        }
    
        private void Display()
        {
           // use f1 here
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the scenario: You have a Windows server that users remotely connect to via
Here's my scenario: I have a simple stored procedure that removes a specific set
Here's my scenario - I have an SSIS job that depends on another prior
Here's the scenario: I have a textbox and a button on a web page.
Here's the scenario: You have an ASP.Net application supported by a Microsoft SQL Server
Here's the scenario I have a Grid with some TextBlock controls, each in a
Here's my scenario: I have a page containing several links; each link is meant
Here's the scenario: I have a set of buttons that I want to bind
Here is the scenario: I have two asp pages. a.aspx is layout and b.aspx
Here's the scenario: We have users login on a secure connection. Could an unathorized

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.