CommonDialog (Clase)
Actualización: noviembre 2007
Especifica la clase base utilizada para mostrar cuadros de diálogo en la pantalla.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
Las clases heredadas deben implementar RunDialog invocando a ShowDialog para crear un cuadro de diálogo común determinado. Las clases derivadas pueden, opcionalmente, reemplazar HookProc para implementar funcionalidad específica de enlace de cuadros de diálogo.
Nota de la plataforma Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows CE:
Esta clase no se admite en .NET Compact Framework actualmente, pero se admitirá en un lanzamiento futuro.
En el siguiente ejemplo de código se utiliza la implementación ColorDialog de CommonDialog y se indica cómo crear y mostrar un cuadro de diálogo. Este ejemplo requiere que se llame al método desde un formulario existente que incluya un control TextBox y otro control Button.
private void button1_Click(object sender, System.EventArgs e) { ColorDialog MyDialog = new ColorDialog(); // Keeps the user from selecting a custom color. MyDialog.AllowFullOpen = false ; // Allows the user to get help. (The default is false.) MyDialog.ShowHelp = true ; // Sets the initial color select to the current text color. MyDialog.Color = textBox1.ForeColor ; // Update the text box color if the user clicks OK if (MyDialog.ShowDialog() == DialogResult.OK) textBox1.ForeColor = MyDialog.Color; }
protected void button1_Click(Object sender, System.EventArgs e)
{
ColorDialog myDialog = new ColorDialog();
// Keeps the user from selecting a custom color.
myDialog.set_AllowFullOpen(false);
// Allows the user to get help. (The default is false.)
myDialog.set_ShowHelp(true);
// Sets the initial color select to the current text color.
myDialog.set_Color(textBox1.get_ForeColor());
// Update the text box color if the user clicks OK
if (myDialog.ShowDialog().Equals(get_DialogResult().OK)) {
textBox1.set_ForeColor(myDialog.get_Color());
}
} //button1_Click
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.CommonDialog
System.Windows.Forms.ColorDialog
System.Windows.Forms.FileDialog
System.Windows.Forms.FolderBrowserDialog
System.Windows.Forms.FontDialog
System.Windows.Forms.PageSetupDialog
System.Windows.Forms.PrintDialog
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.