Visual FoxPro Toolkit for .NET

GetColor() Method

Displays the Color Dialog box and instead of returning a color code this function returns the actual color object. It receives a color object as a parameter and opens the dialog with that color selected

Displays the Color Dialog box and instead of returning a color code this function returns the actual color object

This method is only available in WinForms and not available for ASP.NET WebForms.

[VisualBasic]

Public Shared Function GetColor(ByVal oColor As System.Drawing.Color) As System.Drawing.Color
Public Shared Function GetColor() As System.Drawing.Color

[C#]

public static System.Drawing.Color GetColor(System.Drawing.Color oColor)
public static System.Drawing.Color GetColor()

Example

[VisualBasic]

MyTextBox.ForeColor = GetColor(MyTextBox.ForeColor) 'Pass the current color as a parameter

MyLabel.ForeColor = GetColor()

[C#]

MyLabel.ForeColor = VFPToolkit.dialogs.GetColor(MyLabel.ForeColor);

MyLabel.ForeColor = VFPToolkit.dialogs.GetColor();

Implementation

[VisualBasic]

Public Shared Function GetColor(ByVal oColor As System.Drawing.Color) As System.Drawing.Color
'Create a new ColorDialog object
Dim cd As ColorDialog = New ColorDialog()
'Just in case you do not want customers to create their own colors
'cd.AllowFullOpen = false ;
cd.ShowHelp = True
'Specify the default color to be selected
cd.Color = oColor
'Show the dialog and return the color
cd.ShowDialog()
Return cd.Color
End Function
Public Shared Function GetColor() As System.Drawing.Color
'Create a new default color object
Dim oColor As System.Drawing.Color = New Color()
'Call the overloaded method above and pass the color object to it
Return GetColor(oColor)
End Function

[C#]

public static System.Drawing.Color GetColor(System.Drawing.Color oColor)
{
//Create a new ColorDialog object
ColorDialog cd = new ColorDialog();
//Just in case you do not want customers to create their own colors
//cd.AllowFullOpen = false ;
cd.ShowHelp = true ;
//Specify the default color to be selected
cd.Color = oColor ;
//Show the dialog and return the color
if(cd.ShowDialog() == DialogResult.Cancel)
{
//Visual FoxPro returns the White color when the Cancel button is selected
cd.Color = Color.White;
}
return cd.Color;
}
public static System.Drawing.Color GetColor()
{
//Create a new default color object
System.Drawing.Color oColor = new Color();
//Call the overloaded method above and pass the color object to it
return GetColor(oColor);
}

Requirements

Namespace:VFPToolkit

Class:VFPToolkit.dialogs

Platforms:Windows98, WindowsNT4.0, WindowsMillenniumEdition, Windows2000, WindowsXPHomeEdition, WindowsXPProfessional, Windows.NETServerfamily

Assembly:VFPToolkit (in VFPToolkitNET.dll)

See Also

VFPToolkit.dialogs Members | VFPToolkit Namespace