ComboBox.OnSelectionChangeCommitted(EventArgs) 메서드

정의

SelectionChangeCommitted 이벤트를 발생시킵니다.

protected:
 virtual void OnSelectionChangeCommitted(EventArgs ^ e);
protected virtual void OnSelectionChangeCommitted (EventArgs e);
abstract member OnSelectionChangeCommitted : EventArgs -> unit
override this.OnSelectionChangeCommitted : EventArgs -> unit
Protected Overridable Sub OnSelectionChangeCommitted (e As EventArgs)

매개 변수

e
EventArgs

이벤트 데이터가 포함된 EventArgs입니다.

예제

다음 코드 예제에서는 이벤트 및 SelectionLength 속성을 사용하여 SelectionChangeCommitted 사용자가 선택하고 커밋한 내용에 따라 텍스트 상자의 길이를 변경합니다.

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->SelectedItem->ToString()->Length * 
           ((int)this->textbox1->Font->SizeInPoints);
       textbox1->Text = senderComboBox->SelectedItem->ToString();				
   }
}
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.SelectedItem.ToString().Length *
            ((int) this.textbox1.Font.SizeInPoints);
        textbox1.Text = senderComboBox.SelectedItem.ToString();
    }
}
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.SelectedItem.ToString().Length() * _
            CType(Me.textbox1.Font.SizeInPoints, Integer)
        textbox1.Text = senderComboBox.SelectedItem.ToString()
    End If
End Sub

설명

SelectionChangeCommitted 은 사용자가 콤보 상자 선택을 변경하거나 를 설정할 때만 발생합니다SelectedIndex. 그러나 가 구성된 방법과 ComboBox 사용자가 선택한 항목을 SelectionChangeCommitted 변경하는 방법에 따라 이벤트가 발생하지 않을 수 있습니다. 또는 를 처리할 SelectedIndexChanged수 있지만 이 이벤트는 인덱스가 프로그래밍 방식으로 변경되었는지 사용자에 의해 변경되었는지 여부에 관계없이 발생합니다.

이벤트가 발생하면 대리자를 통해 이벤트 처리기가 호출됩니다. 자세한 내용은 이벤트 처리 및 발생합니다.

또한 OnSelectionChangeCommitted 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고도 이벤트를 처리할 수 있습니다. 이는 파생 클래스에서 이벤트를 처리하는 기본 방법입니다.

상속자 참고

파생 클래스에서 OnSelectionChangeCommitted(EventArgs)를 재정의하는 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnSelectionChangeCommitted(EventArgs) 메서드를 호출해야 합니다.

적용 대상