Properties of RichTextBox at Runtime
-
Hi, I am using a Richtextbox at runtime. and the Control added at runtime But I face a Problem, The RichTextBox Data is Edited or Selected. I am Using ReadOnly=true so that the Edit Mode is Off but Text is still Selecting. If I am take Enabled=false then The Backcolor will be changed. So, How can I a Lock this Control at run Time ? dim rtf01 as new Richtextbox rtf01.Visible = False Me.Controls.Remove(rtf01) Me.Controls.Add(rtf01) rtf01.BringToFront() rtf01.BackColor = Color.FromArgb(175, 175, 175) rtf01.BorderStyle = BorderStyle.None rtf01.Cursor = Cursors.Arrow rtf01.ReadOnly = True rtf01.ScrollBars = RichTextBoxScrollBars.None rtf01.Left = fgButton.Cols(1).Left + 10 rtf01.Top = fgButton.Top + 6 rtf01.Visible = true
Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)
-
Hi, I am using a Richtextbox at runtime. and the Control added at runtime But I face a Problem, The RichTextBox Data is Edited or Selected. I am Using ReadOnly=true so that the Edit Mode is Off but Text is still Selecting. If I am take Enabled=false then The Backcolor will be changed. So, How can I a Lock this Control at run Time ? dim rtf01 as new Richtextbox rtf01.Visible = False Me.Controls.Remove(rtf01) Me.Controls.Add(rtf01) rtf01.BringToFront() rtf01.BackColor = Color.FromArgb(175, 175, 175) rtf01.BorderStyle = BorderStyle.None rtf01.Cursor = Cursors.Arrow rtf01.ReadOnly = True rtf01.ScrollBars = RichTextBoxScrollBars.None rtf01.Left = fgButton.Cols(1).Left + 10 rtf01.Top = fgButton.Top + 6 rtf01.Visible = true
Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)
Why not just have it be readonly? Any reason you do not want to allow user to select text?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Why not just have it be readonly? Any reason you do not want to allow user to select text?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Hi, I am using a Richtextbox at runtime. and the Control added at runtime But I face a Problem, The RichTextBox Data is Edited or Selected. I am Using ReadOnly=true so that the Edit Mode is Off but Text is still Selecting. If I am take Enabled=false then The Backcolor will be changed. So, How can I a Lock this Control at run Time ? dim rtf01 as new Richtextbox rtf01.Visible = False Me.Controls.Remove(rtf01) Me.Controls.Add(rtf01) rtf01.BringToFront() rtf01.BackColor = Color.FromArgb(175, 175, 175) rtf01.BorderStyle = BorderStyle.None rtf01.Cursor = Cursors.Arrow rtf01.ReadOnly = True rtf01.ScrollBars = RichTextBoxScrollBars.None rtf01.Left = fgButton.Cols(1).Left + 10 rtf01.Top = fgButton.Top + 6 rtf01.Visible = true
Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)
In the end of your code:
AddHandler rtf01.SelectionChanged, AddressOf RichTextBox_SelectionChanged
And then create this method:
Private Sub RichTextBox_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
sender.DeselectAll()
End SubThat´s it??
----- LeandroAB
-
Yes I want that the User only click on the Richtextbox, and I'm doing somthing of its click. But When it click the Richtextbox edited.
Arindam Banerjee Sr. Software Developer Rance Computer Pvt Ltd. Kolkata (India)
You could always try using the
KeyPress
event handler, and in the event handler have something likee.Handled=true
. That will force it to ignore all key presses."The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham