![]() ![]() Returns a value indicating whether this converter can convert an object to the given destination type using the context. Returns whether this converter can convert an object of the given type to the type of this converter.ĬanConvertTo(ITypeDescriptorContext, Type) Initializes a new instance of the ColorConverter class.ĬanConvertFrom(ITypeDescriptorContext, Type)ĭetermines if this converter can convert an object in the given source type to the native type of the converter. For example, you should pass "Blue", not "" or "Color.Blue", to the ConvertFrom method. When converting from a string to a Color the ColorConverter expects the unqualified color name otherwise, an exception will occur in the conversion process. (m圜olor)Ĭonverter.ConvertToString(Color.PaleVioletRed)Į.Graphics.DrawString(colorAsString, Me.Font, _ ![]() Private Sub ShowColorConverter(ByVal e As PaintEventArgs)ĭim m圜olor As Color = Color.PaleVioletRedĭim converter As = _ String colorAsString = converter.ConvertToString(Color.PaleVioletRed) Į.Graphics.DrawString(colorAsString, this.Font, Private void ShowColorConverter(PaintEventArgs e) String^ colorAsString = converter->ConvertToString( Color::PaleVioletRed ) Į->Graphics->DrawString( colorAsString, this->Font, Brushes::PaleVioletRed, 50.0F, 50.0F ) System::ComponentModel::TypeConverter^ converter = System::ComponentModel::TypeDescriptor::GetConverter( m圜olor ) void ShowColorConverter( PaintEventArgs^ e ) Paste this code into a form and call the ShowColorConverter method when handling the form's Paint event, passing e as PaintEventArgs. This example is designed to be used with Windows Forms. The following code example demonstrates how to use the ConvertToString method. ![]()
0 Comments
Leave a Reply. |