ComboBox.OnSelectionChangeCommitted メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim e As EventArgs Me.OnSelectionChangeCommitted(e)

SelectionChangeCommitted は、ユーザーがコンボ ボックスの選択項目を変更したときにのみ発生します。SelectedIndexChanged イベントと SelectedValueChanged イベントは、プログラム上で選択項目が変更されたときにも発生するため、ユーザーによる変更をキャプチャする目的でこれらのイベントを使用しないでください。また、このイベントは SelectedIndex を設定するときも発生します。
イベントが発生すると、デリゲートを使用してイベント ハンドラが呼び出されます。詳細については、「イベントの発生」を参照してください。
OnSelectionChangeCommitted メソッドを使用すると、デリゲートを結び付けずに、派生クラスでイベントを処理することもできます。派生クラスでイベントを処理する場合は、この手法をお勧めします。
継承時の注意 派生クラスで OnSelectionChangeCommitted をオーバーライドする場合は、登録されているデリゲートがイベントを受け取ることができるように、基本クラスの OnSelectionChangeCommitted メソッドを呼び出してください。
SelectionChangeCommitted イベントと SelectionLength プロパティを使用して、ユーザーが選択してコミットした項目に応じてテキスト ボックスの長さを変更するコード例を次に示します。
Private Sub comboBox1_SelectionChangeCommitted(ByVal sender _ As Object, ByVal e As EventArgs) _ Handles comboBox1.SelectionChangeCommitted Dim senderComboBox As ComboBox = CType(sender, ComboBox) ' Change the length of the text box depending on what the user has ' selected and committed using the SelectionLength property. If (senderComboBox.SelectionLength > 0) Then textbox1.Width = senderComboBox.SelectionLength * _ CType(Me.textbox1.Font.SizeInPoints, Integer) textbox1.Text = senderComboBox.SelectedText End If End Sub
private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) { ComboBox senderComboBox = (ComboBox) sender; // Change the length of the text box depending on what the user has // selected and committed using the SelectionLength property. if (senderComboBox.SelectionLength > 0) { textbox1.Width = senderComboBox.SelectionLength * ((int) this.textbox1.Font.SizeInPoints); textbox1.Text = senderComboBox.SelectedText; } }
void comboBox1_SelectionChangeCommitted( Object^ sender, EventArgs^ /*e*/ ) { ComboBox^ senderComboBox = dynamic_cast<ComboBox^>(sender); // Change the length of the text box depending on what the user has // selected and committed using the SelectionLength property. if ( senderComboBox->SelectionLength > 0 ) { textbox1->Width = senderComboBox->SelectionLength * ((int)this->textbox1->Font->SizeInPoints); textbox1->Text = senderComboBox->SelectedText; } }
private void comboBox1_SelectionChangeCommitted(Object sender, EventArgs e) { ComboBox senderComboBox = (ComboBox)sender; // Change the length of the text box depending on what the user has // selected and committed using the SelectionLength property. if (senderComboBox.get_SelectionLength() > 0) { textBox1.set_Width(senderComboBox.get_SelectionLength() * (int)( this.textBox1.get_Font().get_SizeInPoints())); textBox1.set_Text(senderComboBox.get_SelectedText()); } } //comboBox1_SelectionChangeCommitted

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ComboBox.OnSelectionChangeCommitted メソッドのページへのリンク