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 equivalent of ddx + q about anchoring

.net equivalent of ddx + q about anchoring

Scheduled Pinned Locked Moved C#
csharpquestionc++wpfwcf
5 Posts 3 Posters 1 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.
  • R Offline
    R Offline
    roel_
    wrote on last edited by
    #1

    Hi, I'm quite new to c# and windows.forms, so these are probably very basic questions :) The first one is: what's the .net equivalent of ddx in mfc? Meaning, how do I associate the values of textboxes and checkboxes etc on forms with members of that forms? I've found ControlBindingsCollection and friends but that seems to be only for binding to databases, I want to bind to normal variables. Secondly, in my dialog I have the following:

    |---| |---|
    | A | XXX | B |
    |---| |---|

    where the two squares A and B are list boxes and the XXX is a button. Now what I want is when the dialog is resized that the button stays the same size and that the two listboxes take up the rest of the space, so that the distance between the right of A and the left of the button stays the same, and the distance between the left of B and the right of the button stays the same as well. I cannot simply set the 'Anchor' property of A and B to 'Left,Top,Right' because that will make them overlap each other, which in turn is caused by the fact that the Anchor is relative to the parent container which is the dialog in this case. How do I do this? (Apart from overriding the dialog's OnSize and positioning everything manually). cheers, roel

    P 1 Reply Last reply
    0
    • R roel_

      Hi, I'm quite new to c# and windows.forms, so these are probably very basic questions :) The first one is: what's the .net equivalent of ddx in mfc? Meaning, how do I associate the values of textboxes and checkboxes etc on forms with members of that forms? I've found ControlBindingsCollection and friends but that seems to be only for binding to databases, I want to bind to normal variables. Secondly, in my dialog I have the following:

      |---| |---|
      | A | XXX | B |
      |---| |---|

      where the two squares A and B are list boxes and the XXX is a button. Now what I want is when the dialog is resized that the button stays the same size and that the two listboxes take up the rest of the space, so that the distance between the right of A and the left of the button stays the same, and the distance between the left of B and the right of the button stays the same as well. I cannot simply set the 'Anchor' property of A and B to 'Left,Top,Right' because that will make them overlap each other, which in turn is caused by the fact that the Anchor is relative to the parent container which is the dialog in this case. How do I do this? (Apart from overriding the dialog's OnSize and positioning everything manually). cheers, roel

      P Offline
      P Offline
      Pradyumna Gogte
      wrote on last edited by
      #2

      Hi Roel, First you have a much better option in c# than the one offered by MFC through the ddx functions. c# or .net controls on your form are true objects and not wrappers as in case of the of MFC. You could directly access the value of the control so in a sence there is no real need to have another variable in the form to store it. You could do something like TextBox.Text to access the value any time you want. However if you still wanted the MFC like functionality then you could probably hook the form validate event and code the actual transfer of data from control to variable manually. Why have this over head when you can access the values directly? For the second problem you cannot do this through setting properties. You have to do this programatically. Cheers, Prady

      R 1 Reply Last reply
      0
      • P Pradyumna Gogte

        Hi Roel, First you have a much better option in c# than the one offered by MFC through the ddx functions. c# or .net controls on your form are true objects and not wrappers as in case of the of MFC. You could directly access the value of the control so in a sence there is no real need to have another variable in the form to store it. You could do something like TextBox.Text to access the value any time you want. However if you still wanted the MFC like functionality then you could probably hook the form validate event and code the actual transfer of data from control to variable manually. Why have this over head when you can access the values directly? For the second problem you cannot do this through setting properties. You have to do this programatically. Cheers, Prady

        R Offline
        R Offline
        roel_
        wrote on last edited by
        #3

        Hello Pradyumna, Thank you for your explanation. The reason I wanted to save to another variable was first because I thought that the controls would not be available anymore once the dialog is closed, and secondly because I'd like to encapsulate the type of control (if I decide to change a textbox with a combobox I'd have to go around around change calls to .Text with calls to .SelectedText). But I've found another way to encapsulate the functionality that I require in my dialog, so for now this problem is not relevant to me any more - but still, it's good to know for the future that there is no equivalent to ddx and that I'll have to save data manually. As for the second part, that's too bad, I thought that with windows forms we'd have layout managers that would be just as powerful as those in eg Java's AWT or in the GTK toolkit. Looks like I was wrong :( Thanks for your time! cheers, roel

        P D 2 Replies Last reply
        0
        • R roel_

          Hello Pradyumna, Thank you for your explanation. The reason I wanted to save to another variable was first because I thought that the controls would not be available anymore once the dialog is closed, and secondly because I'd like to encapsulate the type of control (if I decide to change a textbox with a combobox I'd have to go around around change calls to .Text with calls to .SelectedText). But I've found another way to encapsulate the functionality that I require in my dialog, so for now this problem is not relevant to me any more - but still, it's good to know for the future that there is no equivalent to ddx and that I'll have to save data manually. As for the second part, that's too bad, I thought that with windows forms we'd have layout managers that would be just as powerful as those in eg Java's AWT or in the GTK toolkit. Looks like I was wrong :( Thanks for your time! cheers, roel

          P Offline
          P Offline
          Pradyumna Gogte
          wrote on last edited by
          #4

          Roel, The version 2.0 for the .net framework has the layout mangers in the forms. So may be you can wait for that. Prady

          1 Reply Last reply
          0
          • R roel_

            Hello Pradyumna, Thank you for your explanation. The reason I wanted to save to another variable was first because I thought that the controls would not be available anymore once the dialog is closed, and secondly because I'd like to encapsulate the type of control (if I decide to change a textbox with a combobox I'd have to go around around change calls to .Text with calls to .SelectedText). But I've found another way to encapsulate the functionality that I require in my dialog, so for now this problem is not relevant to me any more - but still, it's good to know for the future that there is no equivalent to ddx and that I'll have to save data manually. As for the second part, that's too bad, I thought that with windows forms we'd have layout managers that would be just as powerful as those in eg Java's AWT or in the GTK toolkit. Looks like I was wrong :( Thanks for your time! cheers, roel

            D Offline
            D Offline
            Dan Neely
            wrote on last edited by
            #5

            roel_ wrote: As for the second part, that's too bad, I thought that with windows forms we'd have layout managers that would be just as powerful as those in eg Java's AWT or in the GTK toolkit. Looks like I was wrong .net 2 is supposed to have a much more complete layout manager. Until then however you're stuck with doing it the hardway if you want anything complex.

            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