Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
725
UltraCombo - Override default selection logic for bound control
posted

Ok I may be going about this all wrong but I'm trying to do something screwy anyway.

On my user control I have an UltraComboBox (ucb)

In the control init (called from Sub New) the ucb is populated from a List of custom object type "OwnerSite"

        With ucb_OwnerRegion
            .DataSource = Shared_Lists.list_OwnerSites
            .ValueMember = "SiteName" '"ID"
            .DisplayMember = "SiteName"
        End With

The contents of this List of type "OwnerSite" is as follows

ID    OwnerSite    RegionCode    RegionName
1    COT            1    
2    COT            2                    Canton/Columbus
3    COT            3    
4    COT            4                    Ft Wayne
5    ROT            5                    Roanoke
6    COT            J    
7    ROT            A                    Abington
8    ROT            H                    Roanoke
9    ROT            J                    Tri State
10  ROT            1    
11  ROT            2    
12  ROT            4   

Next - the ucb is bound to a property of another object of custom object type "RTU"

ucb_OwnerRegion.DataBindings.Add("Value", _rtu, "OwnerSite", True, DataSourceUpdateMode.OnValidation)

The ucb is formatted / styled in it's own init routine

    Private Sub ucb_OwnerRegion_InitializeLayout(sender As Object, e As UltraWinGrid.InitializeLayoutEventArgs) Handles ucb_OwnerRegion.InitializeLayout
        With ucb_OwnerRegion
            .DisplayLayout.Bands(0).Columns("ID").Hidden = True
            .DisplayLayout.Bands(0).Columns("SiteName").Header.VisiblePosition = 0
            .DisplayLayout.Bands(0).Columns("RegionCode").Header.VisiblePosition = 1
            .DisplayLayout.Bands(0).Columns("Description").Header.VisiblePosition = 2
            .AutoCompleteMode = AutoCompleteMode.Suggest
            .AutoSuggestFilterMode = AutoSuggestFilterMode.Contains
            .CharacterCasing = CharacterCasing.Upper
            .DropDownStyle = UltraWinGrid.UltraComboStyle.DropDown
            .LimitToList = True
            .AllowNull = DefaultableBoolean.True
        End With
    End Sub

All fairly straight forward thus far. Now for the funky stuff.

I also have a text box that is bound to another property of the _rtu object

tb_RegionCode.DataBindings.Add("Text", _rtu, "RegionCode", True, DataSourceUpdateMode.OnValidation)

Next in the _RowSelected even of the ucb, I am using the RegionCOde property of the selected row to update the corresponding property on the _rtu object (along with other things I have removed for clarity / brevity)

    Private Sub ucb_OwnerRegion_RowSelected(sender As Object, e As RowSelectedEventArgs) Handles ucb_OwnerRegion.RowSelected
        If ucb_OwnerRegion.SelectedRow Is Nothing Then
            ' Do nothing
        Else

            ' Set RTU Region Code
            _rtu.RegionCode = ucb_OwnerRegion.SelectedRow.Cells("RegionCode").Value.ToString.ToUpper


        'End If 'selectedrow
    End Sub

Now herein lies my problem - When the containing control loads, say the bound property _rtu.OwnerSite = "ROT" and the bound property _rtu.RegionCode = "H"

When the ucb loads it finds the first match for the Ownersite in the list, the RowSelected property fires, and the RegionCode gets set to what ever was in the first matching row (in this case "1" since the list is returned in Ascending Order)

Is there any way that I can override, overload, or otherwise alter the criteria that the ucb uses to pick it's first matching row to include the RegionCode property as well?

I know simpler options would be to just make 2 drop down lists (which is what I am leaning toward) or to store the ID property in my database and use that as the ValueMember property of the ucb. I *can* do this but the application is a replacement for a previous version and has to sit on top of existing data that isn't set up for this and I'd rather not have to refactor the underlying database to maintain compatibility with the old application.

Having to select & set a "RegionCode" at this level is new functionality for the users and in an effort to ease the learning curve I was trying to integrate (sneak LOL) it in with existing data entry.

Thanks in advance. I hope I have explained / provided enough information to at least understand the problem.

Steve

Parents Reply Children
No Data