This documentation is archived and is not being maintained.
FontNamesConverter.ConvertFrom Method
.NET Framework 1.1
Converts a string that represents a list of font names into an array of strings containing individual font names.
Overload List
Converts a string that represents a list of font names into an array of strings containing individual font names.
[Visual Basic] Overloads Overrides Public Function ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) As Object
[C#] public override object ConvertFrom(ITypeDescriptorContext, CultureInfo, object);
[C++] public: Object* ConvertFrom(ITypeDescriptorContext*, CultureInfo*, Object*);
[JScript] public override function ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) : Object;
Inherited from TypeConverter.
[Visual Basic] Overloads Public Function ConvertFrom(Object) As Object
[C#] public object ConvertFrom(object);
[C++] public: Object* ConvertFrom(Object*);
[JScript] public function ConvertFrom(Object) : Object;
Example
[Visual Basic, C#] The following example demonstrates how to use the ConvertFrom method to convert a string with a list of font names to an array of strings containing the individual names.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of ConvertFrom. For other examples that might be available, see the individual overload topics.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub Page_Load(sender As Object, e As EventArgs) ' Declare local variables. Dim culture As New System.Globalization.CultureInfo("en") Dim context As System.ComponentModel.ITypeDescriptorContext = Nothing Dim names As Object Dim name_string As Object ' Create FontNamesConverter object. Dim fontconverter As New FontNamesConverter() ' Create original list of fonts. Dim font_list As String = "arial, times new roman, verdana" ' Check for type compatibility. If fontconverter.CanConvertFrom(context, GetType(String)) Then ' Display original string. Label1.Text = "Original String :" & "<br><br>" & font_list ' Convert string to array to strings and display results. names = fontconverter.ConvertFrom(context, culture, font_list) Label2.Text = "Converted to Array of Strings : " & "<br><br>" Dim name_element As String For Each name_element In CType(names, String()) Label2.Text &= name_element & "<br>" Next name_element ' Convert array of strings back to a string and display results. name_string = fontconverter.ConvertTo(context, culture, names, _ GetType(String)) Label3.Text = "Converted back to String :" & "<br><br>" & _ CType(name_string, String) End If End Sub 'Page_Load </script> </head> <body> <h3>FontNamesConverter Example</h3> <p> <form runat=server> <asp:Label id="Label1" runat="server"/> <br><hr> <asp:Label id="Label2" runat="server"/> <br><hr> <asp:Label id="Label3" runat="server"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void Page_Load(Object sender, EventArgs e) { // Declare local variables. System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en"); System.ComponentModel.ITypeDescriptorContext context = null; Object names; Object name_string; // Create FontNamesConverter object. FontNamesConverter fontconverter = new FontNamesConverter(); // Create original list of fonts. string font_list = "arial, times new roman, verdana"; // Check for type compatibility. if (fontconverter.CanConvertFrom(context, typeof(string))) { // Display original string. Label1.Text = "Original String :" + "<br><br>" + font_list; // Convert string to array to strings and display results. names = fontconverter.ConvertFrom(context, culture, font_list); Label2.Text = "Converted to Array of Strings : " + "<br><br>"; foreach (string name_element in (string[])names) { Label2.Text += name_element + "<br>"; } // Convert array of strings back to a string and display results. name_string = fontconverter.ConvertTo(context, culture, names, typeof(string)); Label3.Text = "Converted back to String :" + "<br><br>" + (string)name_string; } } </script> </head> <body> <h3>FontNamesConverter Example</h3> <p> <form runat=server> <asp:Label id="Label1" runat="server"/> <br><hr> <asp:Label id="Label2" runat="server"/> <br><hr> <asp:Label id="Label3" runat="server"/> </form> </body> </html>
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
See Also
FontNamesConverter Class | FontNamesConverter Members | System.Web.UI.WebControls Namespace
Show: