How to add a string to the top (bottom) of a listbox
at times i'm adding strings list box other times i'm inserting them.
in either case need print on top of listbox not bottom.
troy
tac
sry karen doesn't. else?
troy
tac
well reply of "it doesn't" tells me nothing no new suggestions instead here demo of suggested. 2 listbox controls, listbox1 allow add items in app have own way add items e.g. textbox or other means. press button1 , selected item in listbox1 added or inserted listbox2 depending on if checkbox checked.
using system; using system.data; using system.linq; using system.windows.forms; namespace listboxinsertoradd { public partial class form1 : form { public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { listbox1.items.addrange(enumerable.range(0, 50) .select(item => "item " + item.tostring()).toarray()); listbox1.selectedindex = 1; } private void button1_click(object sender, eventargs e) { if (checkbox1.checked && listbox2.items.count >0) { listbox2.items.insert(0, listbox1.text); } else { listbox2.items.add(listbox1.text); } } } }
please remember mark replies answers if , unmark them if provide no help, others looking solutions same or similar problem. contact via twitter (karen payne) or facebook (karen payne) via msdn profile not answer coding question on either.
vb forums - moderator
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment