0

Using a fixed-width font (e.g. Consolas, Courier, etc), I am trying to populate a dropdown menu (AjaxControlToolkit:DropDownList) that has 2 columns (in appearance). I have a product name and a category name (neither of which I know until runtime). The appearance I'm looking for is something like:

               Chevy Cruz     (gas)
               Prius          (hybrid)
               Tesla Model S  (electic)

My list can have over 300 entries and if I just append the category to the product name, the menu is harder to read.

I've tried using a character array and copying in the category name at the same index for each ListItem, but the spaces between disappear when the dropdown list is opened. I've looked at the ListItem(Paragraph) constuctor but it doesn't look to solve my problem to my understanding of it. I haven't looked at the Telerik controls I have available because it would mean a lot of coding changes.

I can't think of another AjaxControlToolkit control that might help.

Tetsuya Yamamoto
  • 24,297
  • 8
  • 39
  • 61
J T-Rose
  • 1
  • 1
  • Possible duplicate of [Select Multiple Html with columns - possible?](https://stackoverflow.com/questions/25213160/select-multiple-html-with-columns-possible) – Heretic Monkey Jan 08 '19 at 02:21

1 Answers1

0

string padding might be works for you

var _maxLengthOfProductName = 20; //number of space you need
var _productName = "Product Name";
var _type = "(type)";
var _ProductNameWithType = _productName.PadRight(_maxLengthOfProductName, ' ') + _type; //assign this to the dropdown item
_ProductNameWithType = _ProductNameWithType.Replace(" ", " ");

it will show

Product Name        (type)
Fedri Qrueger
  • 641
  • 5
  • 23