Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Reference combobox used on another form?

Reference combobox used on another form?

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kanchoette
    wrote on last edited by
    #1

    I need to reference a combobox value (selectedvalue) on another form to the current form. How can I do this please? I tried setting the combobox modifier to 'Public' and while in NewForm using MainForm.myComboBox.selectedValue without success.

    K 1 Reply Last reply
    0
    • K kanchoette

      I need to reference a combobox value (selectedvalue) on another form to the current form. How can I do this please? I tried setting the combobox modifier to 'Public' and while in NewForm using MainForm.myComboBox.selectedValue without success.

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      Its bad practise to make such properties public as it lessens the object orientation of the control containing the combo box and starts going down the route of coupling the 2nd form to the 1st. The thing to do is to raise an event in the first form (the one containing the combo box) that the second form subscibes to. The event should probably (depending upon your requirements) be raised when the combo box seleceted value changes. Another way to solver you problem is to implement a model-view-viewmodel pattern, but this requires much more work if you have exisiting code.

      CCC solved so far: 2 (including a Hard One!) 37!?!! - Randall, Clerks

      K 1 Reply Last reply
      0
      • K Keith Barrow

        Its bad practise to make such properties public as it lessens the object orientation of the control containing the combo box and starts going down the route of coupling the 2nd form to the 1st. The thing to do is to raise an event in the first form (the one containing the combo box) that the second form subscibes to. The event should probably (depending upon your requirements) be raised when the combo box seleceted value changes. Another way to solver you problem is to implement a model-view-viewmodel pattern, but this requires much more work if you have exisiting code.

        CCC solved so far: 2 (including a Hard One!) 37!?!! - Randall, Clerks

        K Offline
        K Offline
        kanchoette
        wrote on last edited by
        #3

        Many thanks for that. I shall proceed accordingly. :thumbsup:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups