sharat naik
Я решил, что он работает нормально
private void btnMovetoList_Click(object sender, EventArgs e)
{
listBox2.SelectionMode = SelectionMode.MultiSimple;
try
{
List<object> _Objimp = new List<object>();
List<object> _ObjExp = new List<object>();
object _ObjimpList = new object();
object _ObjExpList = new object();
object _ObjStayItem = new object();
if (listBox2.Items.Count > 0)
{
for (int _listtwo = 0; _listtwo < listBox2.Items.Count; _listtwo++)
{
_ObjStayItem = new object();
_ObjStayItem = listBox2.GetItemText(listBox2.Items[_listtwo]);
_Objimp.Add(_ObjStayItem);
}
}
for (int _listtwoSelected = 0; _listtwoSelected < listBox1.SelectedItems.Count; _listtwoSelected++)
{
_ObjimpList = new object();
_ObjimpList = listBox1.GetItemText(listBox1.SelectedItems[_listtwoSelected]);
_Objimp.Add(_ObjimpList);
}
for (int _listboxone = 0; _listboxone < listBox1.Items.Count; _listboxone++)
{
_ObjExpList = new object();
if (!listBox1.GetSelected(_listboxone))
{
_ObjExpList = listBox1.GetItemText(listBox1.Items[_listboxone]);
_ObjExp.Add(_ObjExpList);
}
}
listBox1.DataSource = null;
listBox1.Items.Clear();
listBox2.DataSource = null;
listBox2.Items.Clear();
listBox1.DataSource = _ObjExp.OrderBy(r => r).ToList();
listBox2.DataSource = _Objimp.OrderBy(p => p).ToList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
chkSelectAll1.Checked = false;
}
private void btnMoveReturn_Click(object sender, EventArgs e)
{
try
{
List<object> _Objimp = new List<object>();
List<object> _ObjExp = new List<object>();
object _ObjimpList = new object();
object _ObjExpList = new object();
object _ObjStayItem = new object();
if (listBox1.Items.Count > 0)
{
for (int _listtwo = 0; _listtwo < listBox1.Items.Count; _listtwo++)
{
_ObjStayItem = new object();
_ObjStayItem = listBox1.GetItemText(listBox1.Items[_listtwo]);
_Objimp.Add(_ObjStayItem);
}
}
for (int _listtwoSelected = 0; _listtwoSelected < listBox2.SelectedItems.Count; _listtwoSelected++)
{
_ObjimpList = new object();
_ObjimpList = listBox2.GetItemText(listBox2.SelectedItems[_listtwoSelected]);
_Objimp.Add(_ObjimpList);
}
for (int _listboxone = 0; _listboxone < listBox2.Items.Count; _listboxone++)
{
_ObjExpList = new object();
if (!listBox2.GetSelected(_listboxone))
{
_ObjExpList = listBox2.GetItemText(listBox2.Items[_listboxone]);
_ObjExp.Add(_ObjExpList);
}
}
listBox1.DataSource = null;
listBox1.Items.Clear();
listBox2.DataSource = null;
listBox2.Items.Clear();
listBox2.DataSource = _ObjExp.OrderBy(r => r).ToList();
listBox1.DataSource = _Objimp.OrderBy(p => p).ToList();
chkSelectAll2.Checked = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}