Aaron,
You need to do the following:
Based on the desired configuration of the drop down:
1. Clear the Columns collection of the combo (always do this)
2. create desired columns with properties set
3. Add those columns to combo
4. Change the DropDownFormattingString property to match columns.
Here is some sample code:
Private Sub SetDropDownStyle(ByVal style As String)
'-- Establish locals for our two columns. There is nothing to keep
' us from changing how many columns are are shown in the
' drop down, but we'll use two for both cases in this example.
Dim MultiColumnItem1 As MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem = New MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem
Dim MultiColumnItem2 As MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem = New MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem
Dim ddFormatString As String = String.Empty
'-- Based on some predetermined style, setup combo.
Select Case style
Case "P"
'-- Show a phone number first, then the name. Name column is set wider.
MultiColumnItem1.Name = "Phone"
MultiColumnItem2.Name = "Name"
MultiColumnItem2.Width = 120
'-- Setup format string. These refer to display members setup in the
' population list settings of the combo. {0} is first name,
' {1} is last name and {2} is phone number.
ddFormatString = "{2}|{0} {1}"
Case "N"
'-- Show the name first, then the phone number. Name column is set wider.
MultiColumnItem1.Name = "Name"
MultiColumnItem1.Width = 120
MultiColumnItem2.Name = "Phone"
'-- Setup format string.
ddFormatString = "{0} {1}|{2}"
End Select
'-- Be sure to clear the existing columns so there are no conflicts with the new columns.
Me.cboCustomers.Columns.Clear()
'-- Add the new columns and set format string.
Me.cboCustomers.Columns.AddRange(New MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem() {MultiColumnItem1, MultiColumnItem2})
Me.cboCustomers.PopulationDataSourceSettings.DropDownFormatString = ddFormatString
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'-- Setup combo with "Phone Name" style for drop down.
Me.SetDropDownStyle("P")
'-- You need to requery for the settings to take effect. (settings define how the
' combo is filled, so they do nothing until it is refilled)
Me.cboCustomers.Requery()
End Sub