Jason Meyer

Jason Meyer

  • NA
  • 28
  • 0

Mutiline list box???

Mar 13 2009 4:09 PM

I was wondering if you can have a muli line ListBox with only 1 index for more than one line...

ie. Im working on a restaurant program and for one item i want to display on more than one line... and when you click on a item it highlights all the ones in that index...

small        |\

ham         |   >  these 3 lines i want for 1 index so if i want to delete a item it would delete all 3 lines... 

pepp       |/

-------------------------------------------------------------------------------------------------

medium  |  \

pepp      |  > these 4 lines i want for 1 index

mush      | /

onion     |/

Is there a way to do that with listbox's or a way to somehow code it to work like that????

................................................................................................................................

Well this is what i figured out

int itemCount = 0 // Used for each item added to the list i.e 3 pizzas itemCount = 3

List<int> numberInEach = new List<int>(); // How many lines in each item

// i.e pizza 1: MEDIUM

// WORKS

// pizza 2: LARGE

// HAM

// pizza 3: SMALL

// GREEN PEPPERS

// ONIONS

// so array would have {2,2,3}

int index = listBox1.SelectedIndex; // find which item they picked

bool isFound = false; // if item found than exit while loop

int findItem = 0; // counts the number of lines per item

int count = 0; // used to go thought the numberInEach array

While (isfound == false)

{

findItem += numberInEach[count]; // gets the number for each item and adds it to find the index range

if (findItem < index) // checks to see if item is with-in index

isFound = true;

else

count++;

}

for (int number = numberInEach[count]; number > 0; number--)

{

findItem--;

listBox1.SetSelected(findItem, True); // select each line the item is in

}

Not the best way, i just thought there would be a better way of selecting multipul lines in one index is all

 


Answers (1)