You are on page 1of 4

[CODE]if ((ListBox1.SelectedItems.Count == 0)) { ListBox2.Items.AddRange(ListBox1.Items); ListBox1.Items.

Clear(); } else { for (Int16 i = 0; (i <= (ListBox1.SelectedItems.Count - 1)); i++) { ListBox2.Items.Add(ListBox1.SelectedItems(i)); ListBox1.Items.Remove(ListBox1.SelectedItems(i)); } }[/CODE]

In appropriate event write if (ListBox1.Items.Count == 0 ) { Response.Write("No item to move"); } string itemremoved = ListBox1.SelectedItem.Text; ListBox1.Items.Remove(itemremoved); ListBox2.Items.Add(itemremoved);

public void addListView() { ListView newListView = new ListView(); newListView.AllowDrop = true; newListView.DragDrop += listView_DragDrop; newListView.DragEnter += listView_DragEnter; newListView.MouseDoubleClick += listView_MouseDoubleClick; newListView.MouseDown += listView_MouseDown; newListView.DragOver += listView_DragOver; newListView.Width = 200; newListView.Height = 200; newListView.View = View.Tile; newListView.MultiSelect = false; flowPanel.Controls.Add(newListView); numWO++; numberofWOLabel.Text = numWO.ToString(); }

if (isSizeSet && isLocationSet && isParentSet) { PositionLabel().ParentChanged += new EventHandler(ParentSet). } //Ensures the Size. Location and Parent have been set before adding text bool isSizeSet = false. this. this. EventArgs e) { isParentSet = true. . bool isLocationSet = false.SizeChanged +=new EventHandler(SizeSet). private void SizeSet(object sender. EventArgs e) { isSizeSet = true. EventArgs e) { isLocationSet = true. } } private void LocationSet(object sender. } } private void ParentSet(object sender. } public string TitleLabelText { get. public ListBoxWithTitle() { this. if (isSizeSet && isLocationSet && isParentSet) { PositionLabel().[Category("Custom User Controls")] public class ListBoxWithTitle : ListBox { private Label titleLabel. if (isSizeSet && isLocationSet && isParentSet) { PositionLabel(). bool isParentSet = false. set.LocationChanged +=new EventHandler(LocationSet).

namespace MyLB { /// <summary> /// Summary description for Class1.Windows. } private void MyListBox_Resize(object sender.Controls.Windows.Controls.ProgressBar(). public MyListBox() { this.Location.Parent.Height + 10).Windows.Resize+=new EventHandler(MyListBox_Resize). . this.} } private void PositionLabel() { //Initializes text label titleLabel = new Label().Add(titleLabel). System. titleLabel.Text = TitleLabelText. titleLabel.Forms. this. //Positions the text 10 pixels below the Listbox.Forms. this. titleLabel.Fo rms. } } using System.AutoSize = true.EventArgs e) { Invalidate().Location = new Point(this.ListBox { public System.Location. Size.Add(progress).Y + this.ProgressBar progress = new System. /// </summary> public class MyListBox:System.X.

Add("blablabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb").progress. x <= num.progress.progress.Step = 1. // Loop through for (int x = 1.} } } Next.progress. in the project were you want to use this control. } this.PerformStep(). Add the following code to see the ProgressBar working inside of the listbox: CODE private void TestProgressBar2(int num) { this.myListBox1.Threading. -obislavu- . } You have to decide where to show the ProgressBar inside of the ListBox and how t o handle the area when adding/removing items from the listbox. myListBox1. Now.dll. System. add this new control.Minimum = 1.progress. ToolBox->Add/Remove Item->Browse and locate the MyLB. drag it on your form as a regular control.Sleep(1000).Value = 1.Thread.Items. You should see a new c ontrol in the selected tab. myListBox1.Maximum = num. x++) { myListBox1. myListBox1. You should see a rectangle in th e listbox.progress. myListBox1. na med MyListBox in the ToolBox tab.Visible = true.myListBox1.