Michael
Michael

Reputation: 157

Clear or add items to a list box

I'm rather new to C# so trying to learn how to do different things in c# using visual studio and i need some help

i have a CheckListBox that contains both Deliveries and Pickups when items are selected in the CheckListBox it moves them to a ListBox when i press a button

however i want it to add only deliveries or only pickups to the ListBox, if both a pickup and a delivery is checked and i try to move them i want it to give some kinda or error message like

can't display Both Deliveries & Pickups at the same time

also when i press the button to move them i want it to clear the ListBox if it contains any items then add the items that have been checked in the CheckListBox

I'm not sure how to do this, what would be the simplest way to go about it?

if could give some example code it would be great

Upvotes: 0

Views: 2647

Answers (1)

ddev
ddev

Reputation: 389

YourListBox.Items.Add();

and

if (YourListBox.Items.Count != 0)
{    
YourListBox.Items.Clear();
}

should do the job.

Upvotes: 1

Related Questions