I have two forms and I want one form to display in its Gridview, a data obtain from the combobox of the other form. How do I do that?

I hope I make sense

I might reference you to the 4 links I provided in this post that are all local DaniWeb posts related to transferring variables between forms in C#.

Hopefully one of them helps in your scenario :)

none of those help

none of those help

Really? That's interesting.

So, just to confirm... Your question was:
>>I have two forms and I want one form to display in its Gridview, a data obtain from the combobox of the other form.

What I get from this is you have information in Form A that you want to use in Form B to populate further information with.

I provided you multiple links to references that deal explicitly with transferring information from one form to another but you say this doesn't help you.

Could you perhaps do a favour for those of us who aren't psychic and describe in more detail what you're trying to accomplish and in what way the links didn't help so people might have an idea of where to start then? :twisted:

I did this in form A and it still doesn't pass to the form B when I try to call the binding source

public string Sample
        {
            get
            {
                return sample;
            }
            set
            {
                sample = value;
 
                //Set from property
                this.itemCardBindingSource.Text = this.sample;
            }
        }
  1. In form B, how are you implementing the data call?
  2. How are you referencing form A?
  3. Is the information from form A available globally so that form B is able to see it? or is form B a child of form A?

Not to be picky here but you aren't providing any of the code that specifically shows in what ways you are attempting to derive your value from form A and in what ways it's being implemented into form B. You're also not showing the relationship between the forms or how the forms are instanciated (hmm... is that even a word? :twisted:) which might help others determine if there's a logic error somewhere in your coding or additional steps that might resolve your issue.

thanks for your patient, I am new with programming.

I am struggling with implementing the data call in B.

B is a child of form A

thanks for your patient, I am new with programming.

I am struggling with implementing the data call in B.

B is a child of form A

Ok, we're getting somewhere...

What I think would help here is the following:

  1. Post your code related to the creation of Form B (as child from A)
  2. Post your code related to the determination of the data in Form B that you are attempting to pass
  3. Post your (attempted) code for Form A that you are using to obtain the data you've determined in Form B

Try to keep the code segments that you post here short and related only to these 3 steps and make sure you use the CODE tags to wrap your code so that it maintains it's formatting.

With the above code segments from your project someone in this forum might be able to more specifically identify the exact area that is struggling in this process and point it out for you.

this is my form B where user can make input

private void editSave_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(site))
            {
                MessageBox.Show("Please select a site");
            }
            else
            {
                //Create an item to read input.
                Item inputItem = new Item();
                inputItem.title = ebayTitle.Text;
                inputItem.stitle = this.subTitle.Text;
                inputItem.datePicker1 = this.dateTimePicker1.Text;
                inputItem.timePicker1 = this.timeTimePicker1.Text;
                inputItem.pst = this.pstBox.Text;
                inputItem.startPrice = Convert.ToDecimal(this.StartPrice);
                inputItem.shipping = Convert.ToDecimal(this.Shipping);
                inputItem.bin = this.binBox.Text;
                inputItem.days = this.listingDays.Text;
                inputItem.quantity = this.auctionQuantity.Text;
                inputItem.imageText = this.ImageTextBox.Text;
                inputItem.imageBorder = this.ImageBorderBox.Text;
                NAVaccess nav = new NAVaccess();
                ItemCard[] itemList = nav.getItemCard(inputItem);
                
                Launcher showDialog = new Launcher();

                if (showDialog.ShowDialog(this) == DialogResult.)
                {
                    
                }
                else
                {
                    
                }
                testDialog.Dispose();

                itemList = (ItemCard).itemCardBindingSource.Current;
                siteID = nav.getSiteID(site);
                //MessageBox.Show("Schedule: " + scheduleDate + " site: " + siteID);
                nav.scheduleItem(currentItem, scheduleDate, siteID);
                eBayScheduleTable[] eBayList = nav.getScheduleRug(scheduleDate, siteID);
                List<ItemCard> itemList = new List<ItemCard>();
                scheduleDataGridView.DataSource = eBayList;
                nav.closeNav();
                
            }
        }

so user will click save and it updates gridview in Form A

I am trying to Bind the Combobox properties to the table or a bindingsource in form A

did you close the form B?
if yes, try to use form.hide

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.