实现多控件的互相选择.txt

来自「学习积累的代码段」· 文本 代码 · 共 47 行

TXT
47
字号
	private void Button2_Click(object sender, System.EventArgs e)
		{
		while (ListBox1.Items.Count!=0)
			ListBox2.Items.Add(new ListItem(ListBox1.Items[0].Value ));
			ListBox1.Items.Remove(ListBox1.Items[0].Value);

		}

		private void Button5_Click(object sender, System.EventArgs e)
		{
			while (ListBox2.Items.Count!=0)
				ListBox2.Items.Add(new ListItem(ListBox2.Items[0].Value));
			ListBox2.Items.Remove(ListBox2.Items[0].Value);
		}

		private void Button3_Click(object sender, System.EventArgs e)
		{
			if(ListBox1.SelectedIndex!=-1)
				ListBox2.Items.Add( new ListItem(ListBox1.SelectedItem.Value));
			  ListBox1.Items.Remove(ListBox1.SelectedItem.Value);
		}

		private void Button4_Click(object sender, System.EventArgs e)
		{
			if(ListBox2.SelectedIndex!=-1)
				ListBox1.Items.Add(new ListItem(ListBox2.SelectedItem.Value));
			ListBox2.Items.Remove(ListBox2.SelectedItem.Value);
		}

		private void Button6_Click(object sender, System.EventArgs e)
		{
		    string url;
			if(TextBox1.Text!="")
				{
				url="lianxi2.aspx?TextBox1="+TextBox1.Text;
			Response.Redirect(url);
		}
				  
			else 
			{

					 Label1.Text="请输入用户名";
			       
		
			  
				 }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?