Domanda

I have a Province object, with ProvinceCode and ProvinceName properties. I want to display both in a Visual Webgui (Winforms-based) combobox, with a tab between them.

I am using the PropertyChanged - Format event, as suggested by Eliran's answer to this question:

    private void Province_Format(object sender, ListControlConvertEventArgs e)
    {
        string provCode = ((Province)e.ListItem).ProvinceCode;
        string provName = ((Province)e.ListItem).ProvinceName;
        e.Value = provCode + "\t" + provName;
    }

When the combobox is rendered, the tab displays properly in the textbox area, but displays as a single space in the listbox area.

Does a Winforms combobox support tabs in its listbox area?

Edit: Now have enough reputation to add a picture.

Combobox showing tab in textbox, space in listarea

È stato utile?

Soluzione

Simplest way to achieve this, if your goal is strictly text spacing for display, is to just define and use your own "tab":

public const string TEXT_TAB = "    ";

private void Province_Format(object sender, ListControlConvertEventArgs e)
{
    string provCode = ((Province)e.ListItem).ProvinceCode;
    string provName = ((Province)e.ListItem).ProvinceName;
    e.Value = provCode + TEXT_TAB + provName;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top