Reputation: 361
Dim enteredtext AS STRING = mytextbox.text
mylabel.content = enteredtext
How can i make the entered text that a user enters in a textbox be printed to a label as either bold italic or underlined. These three options shall be enabled with a radio button.
Upvotes: 4
Views: 6727
Reputation: 1992
As above if you are only doing this sometimes and wish to do it in the code behind you can use mylabel.FontStyle = FontStyles.Italic
or if the label always needs to be bold you can look at Font section in the properties tab and choose colur, size, bold, italics, underline, strikeout etc from there.
Upvotes: 1
Reputation: 5366
You can refer the below code.
<Grid>
<StackPanel>
<StackPanel Orientation="Horizontal">
<RadioButton x:Name="rdBold" Checked="RadioButton_Checked" Content="Bold" GroupName="format"/>
<RadioButton x:Name="rdItalics" Checked="rdItalics_Checked" Content="Italics" GroupName="format"/>
<RadioButton x:Name="rdUnderline" Checked="rdUnderline_Checked" Content="Underline" GroupName="format"/>
</StackPanel>
<TextBox x:Name="txtBx" Width="200" Height="20"/>
<TextBlock x:Name="txtBlk" Text="{Binding ElementName=txtBx,Path=Text}"/>
</StackPanel>
</Grid>
Class MainWindow
Private Sub RadioButton_Checked(sender As Object, e As RoutedEventArgs)
txtBlk.FontWeight = FontWeights.Bold
txtBlk.FontStyle = FontStyles.Normal
txtBlk.TextDecorations = Nothing
End Sub
Private Sub rdItalics_Checked(sender As Object, e As RoutedEventArgs)
txtBlk.FontWeight = FontWeights.Normal
txtBlk.FontStyle = FontStyles.Italic
txtBlk.TextDecorations = Nothing
End Sub
Private Sub rdUnderline_Checked(sender As Object, e As RoutedEventArgs)
txtBlk.FontWeight = FontWeights.Normal
txtBlk.FontStyle = FontStyles.Normal
txtBlk.TextDecorations = TextDecorations.Underline
End Sub
End Class
Upvotes: 2
Reputation: 888
You can set the font style for them. e.g.:
mylabel.FontStyle = FontStyles.Italic
Upvotes: 6