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. Form controls data binding sequence

Form controls data binding sequence

Scheduled Pinned Locked Moved C#
csharpdatabasewpfwcfhelp
7 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.
  • X Offline
    X Offline
    Xpnctoc
    wrote on last edited by
    #1

    I'm developing a databound desktop application. On one particular form, I have two list controls -- call them list A and list B. The choices of list B are directly dependent on the selection made in list A. When creating a new record, this is all fine. I make a selection in list A, and the SelectionChanged event triggers a repopulation of the options in list B. The problem comes in on loading a record from a database. Even though I can see the related fields for the A and B selections both have legit data, a list B selection is not being made at data-binding time. Step tracing shows me that .NET is attempting to bind the list B selection first. Since no A selection has been made at that point, the data source for list B is null, and so no selection is made. These "lists" are custom controls, so I could kludge it and put in a "memorized" value that retroactively makes the selection once the control's data source is not null. But that seems like really bad practice. Is there a way to set the sequence of individual control data binding at the form level?

    L 1 Reply Last reply
    0
    • X Xpnctoc

      I'm developing a databound desktop application. On one particular form, I have two list controls -- call them list A and list B. The choices of list B are directly dependent on the selection made in list A. When creating a new record, this is all fine. I make a selection in list A, and the SelectionChanged event triggers a repopulation of the options in list B. The problem comes in on loading a record from a database. Even though I can see the related fields for the A and B selections both have legit data, a list B selection is not being made at data-binding time. Step tracing shows me that .NET is attempting to bind the list B selection first. Since no A selection has been made at that point, the data source for list B is null, and so no selection is made. These "lists" are custom controls, so I could kludge it and put in a "memorized" value that retroactively makes the selection once the control's data source is not null. But that seems like really bad practice. Is there a way to set the sequence of individual control data binding at the form level?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      I think your code is getting confused by SelectionChanged events that indicate something got deselected. When you click an unselected item, you are likely to get two events: one indicating nothing is selected (which you may want to ignore, but it needs code to do that), then one indicating the new selection. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read formatted code with indentation, so please use PRE tags for code snippets.


      I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


      X 1 Reply Last reply
      0
      • L Luc Pattyn

        I think your code is getting confused by SelectionChanged events that indicate something got deselected. When you click an unselected item, you are likely to get two events: one indicating nothing is selected (which you may want to ignore, but it needs code to do that), then one indicating the new selection. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read formatted code with indentation, so please use PRE tags for code snippets.


        I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


        X Offline
        X Offline
        Xpnctoc
        wrote on last edited by
        #3

        That would make sense if these were standard controls. But they are custom controls based on System.Windows.Forms.UserControl -- not inherited from any actual list control like a ListBox. My SelectionChanged() event is a very tightly-coded event that only fires when a value is assigned.

        L 1 Reply Last reply
        0
        • X Xpnctoc

          That would make sense if these were standard controls. But they are custom controls based on System.Windows.Forms.UserControl -- not inherited from any actual list control like a ListBox. My SelectionChanged() event is a very tightly-coded event that only fires when a value is assigned.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          please do not remove a question, it is against the forum guidelines and considered rude. If your problem is solved or no longer relevant to you, leave it as is, but add a marker (such as "solved") to the subject line. If you found the solution yourself, do not hesitate to publish it in the thread, so others can also benefit from it. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          I only read formatted code with indentation, so please use PRE tags for code snippets.


          I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


          X 1 Reply Last reply
          0
          • L Luc Pattyn

            please do not remove a question, it is against the forum guidelines and considered rude. If your problem is solved or no longer relevant to you, leave it as is, but add a marker (such as "solved") to the subject line. If you found the solution yourself, do not hesitate to publish it in the thread, so others can also benefit from it. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            I only read formatted code with indentation, so please use PRE tags for code snippets.


            I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


            X Offline
            X Offline
            Xpnctoc
            wrote on last edited by
            #5

            I apologize. If it's against forum guidelines, then why is a delete option even available? I removed the question because the more I dug the more confused I got. I decided that I really don't know what the heck is going on and need to do a lot more digging. I thought it would be more courteous to remove the thread altogether than to have people waste their time reading it only to get to the point where I say "never mind, I don't know what I'm talking about".

            L 1 Reply Last reply
            0
            • X Xpnctoc

              I apologize. If it's against forum guidelines, then why is a delete option even available? I removed the question because the more I dug the more confused I got. I decided that I really don't know what the heck is going on and need to do a lot more digging. I thought it would be more courteous to remove the thread altogether than to have people waste their time reading it only to get to the point where I say "never mind, I don't know what I'm talking about".

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              well, the remove widget removes a question completely if it has no replies; there is no harm in that. and it replaces the question by "question removed" when there are replies; it really shouldn't be available under those conditions. Removing the head of a thread leaves a sloppy thread; leaving it there may still result in new replies, maybe containing a link to the perfect article dealing with the subject. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


              I only read formatted code with indentation, so please use PRE tags for code snippets.


              I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


              X 1 Reply Last reply
              0
              • L Luc Pattyn

                well, the remove widget removes a question completely if it has no replies; there is no harm in that. and it replaces the question by "question removed" when there are replies; it really shouldn't be available under those conditions. Removing the head of a thread leaves a sloppy thread; leaving it there may still result in new replies, maybe containing a link to the perfect article dealing with the subject. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                I only read formatted code with indentation, so please use PRE tags for code snippets.


                I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                X Offline
                X Offline
                Xpnctoc
                wrote on last edited by
                #7

                Since there was no "remove" widget available, I was hoping that "delete" on the thread root would accomplish the same thing. Seems like the forum codebase itself could use a little tightening ;-)

                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