ユーザーがアイテムを選択したときに、リストボックス(winforms 2.0)に所有者描画変数スタイルを使用しています そのセルに編集コントロールを描画したい それはドロップダウンではなく、セルまたはアイテムに表示される実際の編集コントロールですどうだった?
1 に答える
私はListViewに似たようなものを使用しています。方法は次のとおりです。
TextBoxを作成し、Controls配列に追加して、非表示にします。
innerTextBox.Size = new Size(0、0);
innerTextBox.Location = new Point(0、0);
this.Controls.AddRange(new Control [] {this.innerTextBox});
innerTextBox.KeyPress + = new KeyPressEventHandler(this.EditOver);
innerTextBox.LostFocus + = new EventHandler(this.FocusOver);
innerTextBox.Hide();
innerTextBox.Text = "";
ActiveXイベントで、選択したアイテムを検索してTextBoxに値を取得する独自のメソッドをバインドします
this.DoubleClick + = new EventHandler(this.EditableDoubleClick);
private void EditableDoubleClick(object sender、System.EventArgs e){
selectedItemText = selectedItem.ToString();
innerTextBox.Size = new Size(subItemRect.right --subItemRect.left、subItemRect.bottom --subItemRect.top);
innerTextBox.Location = new Point(subItemRect.left、subItemRect.top);
innerTextBox.Show();
innerTextBox.Text = selectedItemText;
}
TextBoxでフォーカスが失われた場合-選択したアイテムに値を戻します。
selectedItem = innerTextBox.Text;