0
ドロップダウンリスト(DropFont、DropFontSize)とテキストボックス(txtSample)がフォント名とフォントサイズの2つあり、ドロップダウンリストからフォント名を選択すると、テキストボックスのテキストは、希望のフォント名とサイズで変更する必要があります。しかし、私はいくつかのフォントを変更すると、フォントが "普通"をサポートしていないというエラーが表示されます。ISstyleフォントで動作しない利用可能
私は以下のように修正しようとしていますが、今はフォントプロパティが読み取り専用であるというエラーが表示されます。
Try
' Compose the font style.
Dim font_style As FontStyle = FontStyle.Regular
If Bold.Checked Then font_style = font_style Or FontStyle.Bold
If Italic.Checked Then font_style = font_style Or FontStyle.Italic
If Underline.Checked Then font_style = font_style Or FontStyle.Underline
If StrikeOut.Checked Then font_style = font_style Or FontStyle.Strikeout
' Get the font size.
Dim font_size As Single = 8
Try
font_size = Single.Parse(DropFontSize.SelectedValue)
Catch ex As Exception
End Try
' Get the font family name.
Dim family_name As String = "Times New Roman"
If Not (DropFont.SelectedItem Is Nothing) Then
family_name = DropFont.SelectedItem.ToString
End If
' Make the new font.
Dim new_font As New Font(family_name, font_size, font_style)
Catch
End Try
次のようにフォントを設定する:
txtsample.font=new_font// getting error stating that font property is read-only.
個人的には、必要に応じてフォントを変更する要素にCSSクラスを追加します。 – Oliver
イメージ上でこのテキストを透かしとして使用しているので、私に詳しく説明できますか? – coder
どのオブジェクトタイプが 'txtsample'ですか? – Curt