DevEx.ComboBoxEdit if change another comboBoxEdit on some condition back to previous value


DevEx.ComboBoxEdit if change another comboBoxEdit on some condition...
Author
Message
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Hello, I have a problem with binding (I suppose)

I have ComboA and ComboB binded to a BO

When I change ComboA value, ComboB can change to another value

The problem is that if I change comboB value, comboA value change to the previus value

//when combo A (uxIdTipoContribuyente) change I have to change combo B (uxIdTipoDocumento) on some condition if needed

private void uxIdTipoContribuyente_SelectedValueChanged(object sender, EventArgs e)
{
    SetControlDocumento((int)uxIdTipoContribuyente.SelectedValue);
}

//if I have to change the comboB value, I call a method that change that value to an known value

private
 void SetControlDocumento(int idTipoContribuyente)
{
     // this says me if the comboA value have to change comboB value... 
     if (BO.Dic.TiposContribuyentesBO.EsCuitObligatorio(idTipoContribuyente)) { 
          //here I call a user control method that change his combobox control SelectedValue to an known value 
          documentoControl.SetTipoDocumento(TiposDocumentosEnum.CUIT); 
     }
}

// Documentcontrol is a inherited strataframe user control with a combo and a textbox... this method change the selected value of the combo

Documentcontrol.SetTipoDocumento (TiposDocumentosEnum tipoDocumentoId)
{
    uxIdTipoDocumento.SelectedValue = (int)tipoDocumentoId;
    //uxIdTipoDocumento.EditValue = tipoDocumentoId.ToString();
}
// The problem is that when SelectedValue on uxIdtipoDocumento is called, the BO's strataframe businesslayer call the event CurrentView_ListChanged that have this code:
If (Not Me._AreChangedEventsPaused)    Then loDelegate.Invoke(Me.GetPropertyDescriptor(e.PropertyDescriptor.Name), EventArgs.Empty) ...
// this code seems to refresh the value of the datasource and I loose the value that I setted on the combobox A
I have to do it at BO level? to do this I have to set BO's properties on BOM "Property changing events" to single for all / unique for each property and alter values here? or I have to control the "ChangedEventPaused"? (can I?) 
thanks in advance for the help that can bring to me on this problem

Edited 12 Years Ago by Fabian R Silva, -
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Fabian.

Have you tried using the IndexValueChanged event instead?
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Same result using IndexChanged or ValueChanged
the sequence of events firing on this comboboxedit control are:

uxIdTipoContribuyente_editvaluechanged --> here I think that not binding still ocurrs (not 100% sure but if I remember I not use this because can give me the old value on the bo "comboBOBusinessObject.bindingfieldOfThisCombo"

uxIdTipoContribuyente_SelectedIndexChanged
uxIdTipoContribuyente_SelectedValueChanged

index and value changed cause same effect, I not sure if using "changing" intead of "changed" can be a solution Sad 
--------------------------------------------------------------------------------------------------------------------------------------------------------

I go with the PauseChangedEvent way... had never heard of that property before but I tested it and seems to works, edited ok, saved ok... 
I can have future problems using this PauseChangedEvent property, what cares I have to keep present when pausing changed events?
Can I do this change of a property from another property at BO level?(enabling changed properties for this BO)?  it's better because it keep defaults/validate logic separately from the UI?
thanks!

Code that seems to works:
------------------------
public void SetTipoDocumento (TiposDocumentosEnum tipoDocumentoId)
{
    ((BusinessLayer)BusinessObject).PauseChangedEvents();
    uxIdTipoDocumento.SelectedValue = (int)tipoDocumentoId;
    ((BusinessLayer)BusinessObject).ResumeChangedEvents();
}

Edited 12 Years Ago by Fabian R Silva, -
Edhy Rijo
E
StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Fabian,

I would go and handle this on the BO events instead of the UI if possible.  I use the BOM Property Single Event and handle that with a Select Case and update the BO properties instead of the controls in the UI, by updating the BO properties, the UI controls would be updated automatically.

Edhy Rijo

Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)StrataFrame User (261 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Thank you so much, I will refactor my code and go on the BOM single event way. thanks again for the response.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search