Databound combobox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jan v

    #1

    Databound combobox

    Hi everyone.

    I have a user control with 2 comboboxes these comboboxes are Databound to
    the same datatable..
    Wheb 1 add 2 of thos usercontrols (not the comboboxes but the usercontrol
    itself) to one form and change the value in one combobox, then they all (4)
    change there selected value. Does anyone know a way to prevent this from
    happening?

    Thank you in advance



  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Databound combobox

    Jan,

    Since you are binding to the same data table, they are all using the
    default views on the table, which means that they all have the same data
    source. Because of this, when the position changes on one, they change on
    all of them. My suggestion is to create a different instance of the
    DataView class for each combobox, and bind to that.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "jan v" <tght> wrote in message
    news:uAl0Ox0ZDH A.1832@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi everyone.
    >
    > I have a user control with 2 comboboxes these comboboxes are Databound to
    > the same datatable..
    > Wheb 1 add 2 of thos usercontrols (not the comboboxes but the usercontrol
    > itself) to one form and change the value in one combobox, then they all[/color]
    (4)[color=blue]
    > change there selected value. Does anyone know a way to prevent this from
    > happening?
    >
    > Thank you in advance
    >
    >
    >[/color]


    Comment

    • jan v

      #3
      It works thanks


      "jan v" <tght> wrote in message
      news:OowQm60ZDH A.1644@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Ah thanks, didn't thought of that, thats why a combobox has a property
      > sorting, because it has a dataview.
      >
      > I'll try it
      >
      >
      > "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com>[/color]
      wrote[color=blue]
      > in message news:#rsaj40ZDH A.2072@TK2MSFTN GP10.phx.gbl...[color=green]
      > > Jan,
      > >
      > > Since you are binding to the same data table, they are all using the
      > > default views on the table, which means that they all have the same data
      > > source. Because of this, when the position changes on one, they change[/color][/color]
      on[color=blue][color=green]
      > > all of them. My suggestion is to create a different instance of the
      > > DataView class for each combobox, and bind to that.
      > >
      > > Hope this helps.
      > >
      > >
      > > --
      > > - Nicholas Paldino [.NET/C# MVP]
      > > - nicholas.paldin o@exisconsultin g.com
      > >
      > > "jan v" <tght> wrote in message
      > > news:uAl0Ox0ZDH A.1832@TK2MSFTN GP09.phx.gbl...[color=darkred]
      > > > Hi everyone.
      > > >
      > > > I have a user control with 2 comboboxes these comboboxes are Databound[/color][/color]
      > to[color=green][color=darkred]
      > > > the same datatable..
      > > > Wheb 1 add 2 of thos usercontrols (not the comboboxes but the[/color][/color]
      > usercontrol[color=green][color=darkred]
      > > > itself) to one form and change the value in one combobox, then they[/color][/color][/color]
      all[color=blue][color=green]
      > > (4)[color=darkred]
      > > > change there selected value. Does anyone know a way to prevent this[/color][/color][/color]
      from[color=blue][color=green][color=darkred]
      > > > happening?
      > > >
      > > > Thank you in advance
      > > >
      > > >
      > > >[/color]
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...