C#-APP: Displaying TAB in a combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ypytt
    New Member
    • Jul 2008
    • 8

    C#-APP: Displaying TAB in a combo box

    Hi all,
    I'm using C#. I have a DataGridView with a ComboBoxColumn. I'm filling the combo box Items collection programatically , because it is different for each row.
    Each string in the Items list consists of two other strings, read from a table. I want to format the string, so that the list of items appears as if it has two columns.

    When I try the folowing:

    Code:
    ((DataGridViewComboBoxCell)this.dgvModules.Rows[i].Cells[0]).Items.Add(this.m_tableProducts.Rows[j]["Model"].ToString() + "\t" +       this.m_tableProducts.Rows[j]["Name"].ToString());
    a strange symbol like a rectangle appears instead of the tab.

    When I try to simply press tab whithin the "", like this:

    Code:
    ((DataGridViewComboBoxCell)this.dgvModules.Rows[i].Cells[0]).Items.Add(this.m_tableProducts.Rows[j]["Model"].ToString() + "   " +       this.m_tableProducts.Rows[j]["Name"].ToString());
    the items does not appear in two columns.

    What can I do?

    I'm sorry if something is not clear, but English is not my first language.
    Last edited by ypytt; Jul 30 '08, 10:58 AM. Reason: Title made more clear
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    There is a problem with \ & / in c#. Either try "\\t" or @"\t". HTH.

    Comment

    • ypytt
      New Member
      • Jul 2008
      • 8

      #3
      This simply displays \t in my string.

      Maybe I wasn't clear enough. I have two string columns. The first one is with fixed length: 40 characters. I want to construct a third columns containing the two strings separated by some space.
      But when I simply add 4 or 5 empty spaces between the two strings, it does'n look good. It is because the different characters in the font I am using have different width (e.g. A and a). Because of that, the first string have a different width on each row, no matter that it is always 40 characters.
      When I use the tab button in a word-processing program (e.g. Word), the empty space on each row is different, depending on the width of the first string and the text appears as if it is ordered in 2 columns. I want to do something similar in my application.
      I cannot use fixed width font (e.g. Courier), because of user requirements.

      Comment

      Working...