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. .NET Form

.NET Form

Scheduled Pinned Locked Moved C#
csharpgraphicsdesigntutorial
2 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.
  • _ Offline
    _ Offline
    _Tom_
    wrote on last edited by
    #1

    Hi all, I've created a user-control, which resides in library of other controls I use in my application. The control has two or three textboxes and some drawn graphics. I've put this control in my main application and it basically works fine. Next I have a class, and I create an instance which stores my data and I serialise this class to file for use later on. The user-control is used to change the values in this object and I do that using an event which is fired when the TextChanged event occurs. What makes it more complicated is I can have multiple instances of the class which I need to switch between and the user-control needs to display the data in the textboxes for the objectI've selected. My problems see to start when I reload my serialized file or switch between the objects. So for example, when I initialise the control I do: usercontrol.textboxA = X.GetParamA; usercontrol.textboxB = X.GetParamB; When I switch between say object X and Y I do usercontrol.textboxA = Y.GetParamA; // This can cause issues as TextChanged is called usercontrol.textboxB = Y.GetParamB; When the user changes a value in the textbox I fire the event which is caught in the form containing the user-control I do: // Get selected object X or Y in this case Y.GetParamA = usercontrol.textboxA; Y.GetParamB = usercontrol.textboxB; This really doesn't feel like the right way to tackle this and I fear my design is off. I though of passing in a reference to my objects or maybe there is a better way to use the events... Any suggestions would be great. Thanks

    L 1 Reply Last reply
    0
    • _ _Tom_

      Hi all, I've created a user-control, which resides in library of other controls I use in my application. The control has two or three textboxes and some drawn graphics. I've put this control in my main application and it basically works fine. Next I have a class, and I create an instance which stores my data and I serialise this class to file for use later on. The user-control is used to change the values in this object and I do that using an event which is fired when the TextChanged event occurs. What makes it more complicated is I can have multiple instances of the class which I need to switch between and the user-control needs to display the data in the textboxes for the objectI've selected. My problems see to start when I reload my serialized file or switch between the objects. So for example, when I initialise the control I do: usercontrol.textboxA = X.GetParamA; usercontrol.textboxB = X.GetParamB; When I switch between say object X and Y I do usercontrol.textboxA = Y.GetParamA; // This can cause issues as TextChanged is called usercontrol.textboxB = Y.GetParamB; When the user changes a value in the textbox I fire the event which is caught in the form containing the user-control I do: // Get selected object X or Y in this case Y.GetParamA = usercontrol.textboxA; Y.GetParamB = usercontrol.textboxB; This really doesn't feel like the right way to tackle this and I fear my design is off. I though of passing in a reference to my objects or maybe there is a better way to use the events... Any suggestions would be great. Thanks

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Looks ok to me, remember most of your work revolves changing data from one format to another and vice versa.

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)

      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