ComboBox.SelectionChangeCommitted (Evento)
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)
SelectionChangeCommitted sólo se produce cuando el usuario cambia la selección del cuadro combinado. No utilice SelectedIndexChanged o SelectedValueChanged para capturar los cambios del usuario, ya que esos eventos también se provocan cuando la selección cambia mediante programación.
Se puede crear un controlador de eventos SelectionChangeCommitted para proporcionar un control especial en el ComboBox cuando el usuario cambia el elemento seleccionado de la lista.
Para obtener más información sobre la forma de controlar eventos, vea Utilizar eventos.
En el ejemplo de código siguiente se usa el evento SelectionChangeCommitted y la propiedad SelectionLength para cambiar la longitud del cuadro de texto dependiendo de lo que haya seleccionado y confirmado el usuario.
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; } }
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 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter
Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.