C# winforms で追加と削除のコンテナーを設計しようとしています。リストボックスを使用してそれを達成しようとしています。現在、リストボックス1にはコンボボックスとその他のアイテムが含まれています。この点に関して 2 つの質問があります。
非コンボ ボックス項目を定義するには、どのコントロールを使用すればよいですか? 他のフォームでは、これらのコントロールを選択すると、Excel シートが開きます。この場合、コンボ ボックスで選択した値に基づいてデータをフィルター処理することにより、同様の操作になります。
この listbox1 と listbox2 を作成するにはどうすればよいですか? また、あるリストボックスから別のリストボックスにアイテムを追加および削除するためにこれまでに書いたコードは正しいですか?
これまでに作成した全体的なコードは次のとおりです。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class DataFilter : Form
{
public DataFilter()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
this.Controls.Clear();
this.InitializeComponent();
}
private void indexerbtn_Click(object sender, EventArgs e)
{
Indexer ins = new Indexer();
ins.MdiParent = this.MdiParent;
this.Hide();
ins.ShowDialog();
}
private void MoveListBoxItems(ListBox source, ListBox destination)
{
ListBox.SelectedObjectCollection sourceItems = source.SelectedItems;
foreach (var item in sourceItems)
{
destination.Items.Add(item);
}
while (source.SelectedItems.Count > 0)
{
source.Items.Remove(source.SelectedItems[0]);
}
}
private void button1_Click(object sender, EventArgs e)
{
MoveListBoxItems(listBox1, listBox2);
}
private void button2_Click(object sender, EventArgs e)
{
MoveListBoxItems(listBox2, listBox1);
}
}
}
................................................................... ......................................... メールアドレスを教えてください. 目的をよりよく説明できるデザインのスクリーンショットを送ることができます。