NOTE:-
CODE:
using System;
using System.Windows.Forms;
namespace ListBoxesMoveTextWF
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void PictMoveOne_Click(object sender, EventArgs e)
{
try
{
int pos = SourceListBox.SelectedIndex;
if (pos == -1)
{
return;
}
Object selected = SourceListBox.SelectedItem;
TargetListBox.Items.Add(selected);
SourceListBox.Items.RemoveAt(pos);
SourceListBox.SelectedIndex = pos;
}
catch (ArgumentOutOfRangeException)
{
SourceListBox.SelectedIndex = SourceListBox.Items.Count - 1;
}
}
}
}
ListBox Properties
- SelectionMode= None|One|MultiSimple|MultiExtended
- MultiColumn= True|False
- SelectedIndex
- SelectedItem
- SelectedItems
- Sorted=true|false
- ListBox.SelectedIndex= -1 implies that no item is selected.
ListBox Methods
- Insert()
- Remove()
- SetSelected()
No comments:
Post a Comment