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 RegionName1 COT 1 2 COT 2 Canton/Columbus3 COT 3 4 COT 4 Ft Wayne5 ROT 5 Roanoke6 COT J 7 ROT A Abington8 ROT H Roanoke9 ROT J Tri State10 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
Hristo,
That works beautifully.
Thank you very much
Hello,
If you want to manipulate binding, Binding class provides you tow events Format and Parse. More information about those events you will find on the following links:
http://msdn.microsoft.com/en-us/library/system.windows.forms.binding.format%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
http://msdn.microsoft.com/en-us/library/system.windows.forms.binding.parse%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
About UltraCombo, it is designed to select first value that match search criteria. What I could suggest you is instead to bind UltraCombo, use Format event of Binding objects of the _rtu and in this event manually to set SelectedRow property of UltraCombo to a corresponding UltraGridRow from the UltraCombo’s dropdown that meets your criteria for search in the combo rows.
I hope that this will helps you