﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Change Combobox column order at runtime</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Thu, 17 Sep 2026 18:07:54 GMT</lastBuildDate><ttl>20</ttl><item><title>Change Combobox column order at runtime</title><link>http://forum.strataframe.net/FindPost24920.aspx</link><description>Hi,&lt;br&gt;
&lt;br&gt;
Is it possible to switch around the column order in a multi-column combobox at runtime? For example, I have a customer dropdown with two columns (accno and name). I normally show the accno on the left before the name. However, some users would like to see it the other way around so I would like to be able to do that at run time.&lt;br&gt;
&lt;br&gt;
Can the columns be switched around at runtime?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Aaron</description><pubDate>Mon, 19 Oct 2009 09:31:57 GMT</pubDate><dc:creator>Aaron Young</dc:creator></item><item><title>RE: Change Combobox column order at runtime</title><link>http://forum.strataframe.net/FindPost24942.aspx</link><description>Excellent! Glad you go it going.</description><pubDate>Mon, 19 Oct 2009 09:31:57 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Change Combobox column order at runtime</title><link>http://forum.strataframe.net/FindPost24939.aspx</link><description>Thanks Greg, works a treat! :)&lt;br&gt;
&lt;br&gt;
Many thanks!</description><pubDate>Mon, 19 Oct 2009 05:49:37 GMT</pubDate><dc:creator>Aaron Young</dc:creator></item><item><title>RE: Change Combobox column order at runtime</title><link>http://forum.strataframe.net/FindPost24928.aspx</link><description>Any time. Let us know if you get it working.</description><pubDate>Thu, 15 Oct 2009 13:42:54 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Change Combobox column order at runtime</title><link>http://forum.strataframe.net/FindPost24927.aspx</link><description>Thanks Greg. I will give this a try.&lt;/P&gt;&lt;P&gt;I really appreciate your time and help on this one :)&lt;/P&gt;&lt;P&gt;Thanks again</description><pubDate>Thu, 15 Oct 2009 13:18:28 GMT</pubDate><dc:creator>Aaron Young</dc:creator></item><item><title>RE: Change Combobox column order at runtime</title><link>http://forum.strataframe.net/FindPost24926.aspx</link><description>Aaron,&lt;br&gt;
&lt;br&gt;
You need to do the following:&lt;br&gt;
&lt;br&gt;
Based on the desired configuration of the drop down:&lt;br&gt;
&lt;br&gt;
1. Clear the Columns collection of the combo (always do this)&lt;br&gt;
2. create desired columns with properties set&lt;br&gt;
3. Add those columns to combo&lt;br&gt;
4. Change the DropDownFormattingString property to match columns.&lt;br&gt;
&lt;br&gt;
Here is some sample code:&lt;br&gt;
&lt;br&gt;
[codesnippet]Private Sub SetDropDownStyle(ByVal style As String)&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Establish locals for our two columns. There is nothing to keep&lt;br&gt;
&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;&amp;nbsp;us from changing how many columns are are shown in the&lt;br&gt;
&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;&amp;nbsp;drop down, but we'll use two for both cases in this example.&lt;br&gt;
&amp;nbsp;&amp;nbsp;Dim MultiColumnItem1 As MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem = New MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem&lt;br&gt;
&amp;nbsp;&amp;nbsp;Dim MultiColumnItem2 As MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem = New MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem&lt;br&gt;
&amp;nbsp;&amp;nbsp;Dim ddFormatString As String = String.Empty&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Based on some predetermined style, setup combo.&lt;br&gt;
&amp;nbsp;&amp;nbsp;Select Case style&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case "P"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'-- Show a phone number first, then the name. Name column is set wider.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MultiColumnItem1.Name = "Phone"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MultiColumnItem2.Name = "Name"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MultiColumnItem2.Width = 120&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'-- Setup format string. These refer to display members setup in the &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;&amp;nbsp;population list settings of the combo. {0} is first name,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;&amp;nbsp;{1} is last name and {2} is phone number.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ddFormatString = "{2}|{0} {1}"&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case "N"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'-- Show the name first, then the phone number. Name column is set wider.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MultiColumnItem1.Name = "Name"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MultiColumnItem1.Width = 120&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MultiColumnItem2.Name = "Phone"&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'-- Setup format string. &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ddFormatString = "{0} {1}|{2}"&lt;br&gt;
&amp;nbsp;&amp;nbsp;End Select&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Be sure to clear the existing columns so there are no conflicts with the new columns.&lt;br&gt;
&amp;nbsp;&amp;nbsp;Me.cboCustomers.Columns.Clear()&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Add the new columns and set format string.&lt;br&gt;
&amp;nbsp;&amp;nbsp;Me.cboCustomers.Columns.AddRange(New MicroFour.StrataFrame.UI.Windows.Forms.MultiColumnItem() {MultiColumnItem1, MultiColumnItem2})&lt;br&gt;
&amp;nbsp;&amp;nbsp;Me.cboCustomers.PopulationDataSourceSettings.DropDownFormatString = ddFormatString&lt;br&gt;
End Sub&lt;br&gt;
&lt;br&gt;
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Setup combo with "Phone Name" style for drop down.&lt;br&gt;
&amp;nbsp;&amp;nbsp;Me.SetDropDownStyle("P")&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- You need to requery for the settings to take effect. (settings define how the &lt;br&gt;
&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;&amp;nbsp;combo is filled, so they do nothing until it is refilled)&lt;br&gt;
&amp;nbsp;&amp;nbsp;Me.cboCustomers.Requery()&lt;br&gt;
End Sub&lt;br&gt;
&lt;br&gt;
[/codesnippet]</description><pubDate>Thu, 15 Oct 2009 12:56:55 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Change Combobox column order at runtime</title><link>http://forum.strataframe.net/FindPost24923.aspx</link><description>Thanks Greg,&lt;br&gt;
&lt;br&gt;
I should have included in my post but I originally tried changing the PopulationDataSourceSettings but it doesn't change the order. It looks like the combobox has to be reset in some way after the changes have been made and that is what I am missing.&lt;br&gt;
&lt;br&gt;
Aaron</description><pubDate>Thu, 15 Oct 2009 09:47:59 GMT</pubDate><dc:creator>Aaron Young</dc:creator></item><item><title>RE: Change Combobox column order at runtime</title><link>http://forum.strataframe.net/FindPost24922.aspx</link><description>You could just have code to reset the appropriate property (not sure what its called) at runtime. Take a look in the designer file in the InitializeComponent method and you'll see it.</description><pubDate>Thu, 15 Oct 2009 08:58:55 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>