The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

One collection, multiple instances of a form, each with a bound combobox

Last post 03-19-2007, 12:27 PM by quimbo. 3 replies.
Sort Posts: Previous Next
  •  03-19-2007, 9:36 AM 1146

    One collection, multiple instances of a form, each with a bound combobox

    I have some static collections that I load at startup:

     

     

    Code:
    CallTypes = New BusinessObjects.CallTypeCollection
    CallTypes.es.Connection.Name = "SQLCLP"
    CallTypes.LoadAll()

     I then have a form with a combobox where i bind the combo to the collection:

     

     

    Code:
            Me.uxCallTypes.DataSource = Nothing
    Me
    .uxCallTypes.DataSource = CallTypes
    Me.uxCallTypes.DisplayMember = BusinessObjects.CallTypeMetadata.ColumnNames.Calltype
    Me.uxCallTypes.ValueMember = BusinessObjects.CallTypeMetadata.ColumnNames.CallTypeID
    Me.uxCallTypes.SelectedIndex = -1
     
    and i have this databinding:
     
    Code:
            Me.uxCallTypes.DataBindings.Add(New Binding("SelectedValue", entity, 
                  BusinessObjects.CallRequestMetadata.PropertyNames.CallTypeID, True, DataSourceUpdateMode.OnPropertyChanged))
     
    The problem i have is that i can have multiple copies of the same form open at once, 
    so whichever value is selected in the most recently changed form is then selected for 
    all other instances of the form since they are using the same datasource.
    I know i can create a collection local to each form instance, but don't want to have to incur  
    the overhead of loading it each and every time.
     
    How can i accomplish different selected values on different instances of a form? 
     
     
     
     
     
     
     
  •  03-19-2007, 10:24 AM 1152 in reply to 1146

    Re: One collection, multiple instances of a form, each with a bound combobox

    This is a .NET issue, I think you need to use the CurrencyManager (terribly named) class, look up how to use that in MSDN help, it's either that or you do this for each combo or listbox.

    this.comboBox1.BindingContext = new BindingContext();

    If you can't figure it out let us know, if you do please post a sample, I've done this a number of times and always seem to forget the solution. 


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  03-19-2007, 10:25 AM 1153 in reply to 1152

    Re: One collection, multiple instances of a form, each with a bound combobox

    Further help see HERE

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  03-19-2007, 12:27 PM 1163 in reply to 1153

    Re: One collection, multiple instances of a form, each with a bound combobox

    that worked, thanx much

     

     

    Code:
            Me.uxRoute.Visible = False
    Me
    .uxRoute.DataSource = Nothing
    Me
    .uxRoute.DataSource = RouteCollection
    Me.uxRoute.BindingContext = New BindingContext()
    Me.uxRoute.DisplayMember = BusinessObjects.RouteMetadata.ColumnNames.RouteName
    Me.uxRoute.ValueMember = BusinessObjects.RouteMetadata.ColumnNames.RouteID
    Me.uxRoute.SelectedIndex = -1
    Me.uxRoute.Visible = True
     
View as RSS news feed in XML