Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear all

I have richtextbox1 in that its already font size increasing though Ctrl+mousewheeel but i want to increase and decrease font size through Keyboard shortcut like Ctrl+Uparrow (increase font size)and Ctrl+Downarrow (decrease font size) or Ctrl++(increasing) and Ctrl+-(decreasing) or Ctrl+](increasing) and Ctrl+[(Decreasing)

What I have tried:

If e.KeyCode = Keys.Ctrl+[ Then
Posted
Updated 20-Oct-19 20:45pm

1 solution

Private Sub RichTextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles RichTextBox1.KeyDown

    If e.KeyCode = Keys.Add AndAlso e.Modifiers = Keys.Control Then
        'increase the font size
    ElseIf e.KeyCode = Keys.Subtract AndAlso e.Modifiers = Keys.Control Then
        'decrease the font size
    End If

End Sub
 
Share this answer
 
Comments
Member 14621280 21-Oct-19 13:18pm    
it wont work
Member 14621280 21-Oct-19 13:19pm    
which key i should press to increase and decrease
Member 14621280 21-Oct-19 13:24pm    
Private Sub RichTextBox2_KeyDown(sender As Object, e As KeyEventArgs) Handles RichTextBox2.KeyDown
If e.KeyCode = Keys.Tab Then
RichTextBox1.Show()
RichTextBox2.Visible = False
RichTextBox1.Visible = True

If e.KeyCode = Keys.Up AndAlso e.Modifiers = Keys.Control Then
'increase the font size
ElseIf e.KeyCode = Keys.Down AndAlso e.Modifiers = Keys.Control Then
'decrease the font size
End If

End If
End Sub
kgmmurugesh 22-Oct-19 0:47am    
ctrl+ to increase and ctrl- to decrease
kgmmurugesh 22-Oct-19 1:05am    
Private Sub RichTextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles RichTextBox1.KeyDown

If e.KeyCode = Keys.Add AndAlso e.Modifiers = Keys.Control Then
'increase the font size
RichTextBox1.Font = New System.Drawing.Font(RichTextBox1.Font.Name,
RichTextBox1.Font.Size + 1)
ElseIf e.KeyCode = Keys.Subtract AndAlso e.Modifiers = Keys.Control Then
'decrease the font size
RichTextBox1.Font = New System.Drawing.Font(RichTextBox1.Font.Name,
RichTextBox1.Font.Size - 1)
End If

End Sub

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900