4 Replies - 3987 Views - Last Post: 01 February 2010 - 01:52 PM Rate Topic: -----

#1 Elekes Istvan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 07-March 09

How to declare a combobox public in c#

Posted 01 February 2010 - 01:24 PM

Hello! I have a c# project, in which exist one combobox. After clicking a button, an other form is loaded, in which I want to refresh the combobox. But in this second form, the combobox is not recognized. How can I make the combo public?
Thanks for any help.
EI
Is This A Good Question/Topic? 0
  • +

Replies To: How to declare a combobox public in c#

#2 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 382
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: How to declare a combobox public in c#

Posted 01 February 2010 - 01:32 PM

You can try setting the combobox Modifiers property from private to public. Better solution would be to access it through an instance of your first form.
Was This Post Helpful? 0
  • +
  • -

#3 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 526
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: How to declare a combobox public in c#

Posted 01 February 2010 - 01:36 PM

If it's windows forms code, then you can go to the other piece of your partial class which is the designer and declare that combobox public.

Now, you CAN do that. Is that a good idea? Na, not really.

Why does form 2 have to access a combo box in form 1? Can you post your code. I think there might be a logic mix up that should be remedied.
Was This Post Helpful? 0
  • +
  • -

#4 Elekes Istvan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 07-March 09

Re: How to declare a combobox public in c#

Posted 01 February 2010 - 01:45 PM

View PostMentalFloss, on 1 Feb, 2010 - 12:36 PM, said:

If it's windows forms code, then you can go to the other piece of your partial class which is the designer and declare that combobox public.

Now, you CAN do that. Is that a good idea? Na, not really.

Why does form 2 have to access a combo box in form 1? Can you post your code. I think there might be a logic mix up that should be remedied.


Thanks for your amability! Well, in the combobox Iput 1 column of a data table. The correspondent other columns are listed in different textboxoes. Now, I want to modify one element of a textbox. For this, after clicking the label near the textbox, are loaded a new form, in wich I give the new value, and after this, I updated the data table. In this moment it is neccesary to refresh the combobox, because I want to see the result of changing.
Was This Post Helpful? 0
  • +
  • -

#5 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 526
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: How to declare a combobox public in c#

Posted 01 February 2010 - 01:52 PM

Look into data binding controls
http://msdn.microsof...y/ms752347.aspx

With it bound to a data table, it should refresh automatically when changed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1