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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:40:51+00:00 2026-06-17T17:40:51+00:00

What im trying to do: Search products by BarCode on Form1 form; if it

  • 0

What im trying to do:

  1. Search products by BarCode on Form1 form;
  2. if it cannot be found:
    1. Open Inventory form
    2. Search product by name or description
    3. On ListView click on the found product copy its BarCode and paste it to the Form1 barcode textbox.

All that is done corectly. The problem is that every time I add product from Inventory form a new Form1 is opened.

The values are not processed in the same Form1, so assume I sell 4 products:

  • 2 of them are added through Form1 barcode search
  • 2 of them are added through Inventory search form

In the end I get 3 opened Form1 forms, one with 2 products and two forms with single product (added through Inventory form). I need them to be all in one.

Thanks

//————————-Form1——————————————–

private void btnInventory_Click(object sender, EventArgs e)

    {
        Inventory Inventory = new Inventory();
        Inventory.Show();
    }



 private string _theValue;

    public string TheValue
    {
        get
        {
            return _theValue;
        }
        set
        {
            _theValue = value;
            txtItems.Text = value;

        }
    }

//—————————–Inventory———————————

private void ShowForm1()
    {

        string value = label9.Text;
        Form1 newForm = new Form1();
        newForm.TheValue = value;
        this.Close();
        newForm.ShowDialog();
    }



private void lvList_Click(object sender, EventArgs e)

    {
        label9.Text = lvList.SelectedItems[0].SubItems[0].Text;
        this.ShowForm1();

    }

Im sorry for the delay, i had to wait 8h before posting again

Thanks for ur reply.

I just tried that
Form1

  private void btnInventory_Click(object sender, EventArgs e)
     {

         Inventory _inv = new Inventory();
         if (DialogResult.OK == _inv.ShowDialog())
             {
                 txtItems.Text = _inv.fugi;
             }

     }

and in Inventory Form

private string test;
        public string fugi
        {
            get { return test; }
            set { test = label9.Text; }
        }



private void lvList_Click(object sender, EventArgs e)
        {

            label9.Text = lvList.SelectedItems[0].SubItems[0].Text;
            this.DialogResult = DialogResult.OK;
            this.Close();


        }

txtItems.Text does not get the value of test from inventory form

  • 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-17T17:40:52+00:00Added an answer on June 17, 2026 at 5:40 pm

    Its opening a new dialog because you tell it to in ShowForm1, Personally I would change your btnInventory click as follows

    private void btnInventory_Click(object sender, EventArgs e)
    {
        Inventory _inv = new Inventory();
        if(DialogResult.OK == Inventory.ShowDialog())
        {
              valueIWantToSet = _inv.Accessor;
        }
    }
    

    Accessor you will need to make yourself similar to

    public TypeOfVar Accessor
    {
        get{return m_privateVariableThatIWillMakeAndSetToMyBarcode;}
    }
    

    Edit:
    Once you have gotten the value of your barcode you need to set DialogResult as Follows

     this.DialogResult = DialogResult.OK;
    

    and then set the variable you wish to access to the barcode before closing your form

    Edit2:
    Your ShowForm1 will end up similar to this (May want to rename this method!)

    {
    this.DialogResult = DialogResult.OK;
    m_myVar = SelectedItem..;
    this.Close;
    }
    

    UPDATE ANSWER

    You are still having problems as you haven’t used the set property correctly, your get is fine as it is. There is a keyword in c# called value that should be used for setters. this value will take the value of whatever is on the right hand side of an = sign.. you can think of it like this…

    fugi = label9.Text

    In the above line, fugi is using your properties getter in order to get the value that needs to be set to label9.Text. The = sign says that you intend to use the setter for this property and set the value of value to label9.Text.

    Properties with a getter and setter are used so you do not have to provide access to the underlying variable to somewhere you would not like to and then can have the option to just set or get this variable as needed.

    This means that your problem persists have you have yet to set the value of test, it is still the default string value.
    So you have a couple of ways to solve your problem.

    The first way is just to provide a getter for label9.Text and remove the need for your private variable.

    public string Fugi //Properties should really start with capital letter
    {
        get{return label9.Text;}
    }
    

    The second is to set the value of test before you call your getter in btnInventoryClick and remove the setter method

    private void lvList_Click(object sender, EventArgs e)
    {
       test = label9.Text;
    

    and the third ist to set test as shown in method 2 but also change the set method of Fugi to the following to allow this test variable to be set elsewhere.

    set{text = value;}

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

Sidebar

Related Questions

So I'm trying to search through a model through a form. Basically my end
I am trying to build a product search for a jewelry store. I know
I'm trying to create a catalogue that site users can search to find products
I'm trying to use LucidWorks (http://www.lucidimagination.com/products/lucidworks-search-platform) as a search engine for my organization intranet.
I'm trying to get a product search to work properly in MySQL 5.0.88. Basic
So im trying to populate an auto-complete search form from my database. Here is
I am trying do a search to make sure that each of our product
I'm trying to make mini search engine for a site containing products. I've already
While trying to search with id sorting (and paginating) im getting from the log:
Im trying to search two of the fields in my table. (Database table contains

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.