Click here to Skip to main content
15,889,335 members
Home / Discussions / Windows Forms
   

Windows Forms

 
QuestionDisabling scrolling in RichTextBox ?? Pin
ashkan87_224-Aug-09 0:12
ashkan87_224-Aug-09 0:12 
AnswerRe: Disabling scrolling in RichTextBox ?? Pin
εїзεїзεїз24-Aug-09 15:19
εїзεїзεїз24-Aug-09 15:19 
GeneralRe: Disabling scrolling in RichTextBox ?? Pin
ashkan87_225-Aug-09 0:11
ashkan87_225-Aug-09 0:11 
RantStupid Scrollbar bug Pin
LloydA11123-Aug-09 8:43
LloydA11123-Aug-09 8:43 
GeneralRe: Stupid Scrollbar bug Pin
Alan N23-Aug-09 13:01
Alan N23-Aug-09 13:01 
GeneralRe: Stupid Scrollbar bug Pin
εїзεїзεїз23-Aug-09 14:55
εїзεїзεїз23-Aug-09 14:55 
GeneralRe: Stupid Scrollbar bug Pin
molesworth24-Aug-09 6:59
molesworth24-Aug-09 6:59 
QuestionIn RichTextBox, changing WordWrap affects Undo/Redo? Pin
Alan Burkhart22-Aug-09 8:46
Alan Burkhart22-Aug-09 8:46 
I kept wondering why my Undo/Redo buttons sometimes didn't work as expected. Just noticed that toggling the WordWrap on and off is the culprit. Has anyone else encountered this?

The code below is a stripped down version just to illustrate the problem. Paste it into a form called "Form1". Drag in a RichTextBox named "rtf" and a ToolStrip. Add 3 buttons to the ToolStrip:

  • tb_Undo
  • tb_UndoWW
  • tb_WW


Set the CheckOnClick property for tb_WW to true (toggles the WordWrap in the RTB).

Here's the code:

VB
Private Sub tb_Undo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_Undo.Click
  'Enabled property not affected by other code
  rtf.Undo()

End Sub

Private Sub tb_UndoWW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_UndoWW.Click
  'Enabled property affected by rtf.SelectionChanged event handler
  If rtf.CanUndo Then
    rtf.Undo()
  End If
End Sub

Private Sub tb_WW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_WW.Click
  'toggle word wrap
  rtf.WordWrap = tb_WW.Checked

End Sub

Private Sub rtf_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtf.SelectionChanged
  'selection changes when word wrap is toggled
  'enables / disables tb_UndoWW
  tb_UndoWW.Enabled = rtf.CanUndo

End Sub


Add some text the RichTextBox, then backspace or whatever to change it. Then toggle the word wrap a time or two. Watch the tb_UndoWW ToolStrip button. It'll disable because the CanUndo property changes to false.

Is this a bug (couldn't find it at MSDN) or am I doing something really dumb here?
AnswerRe: In RichTextBox, changing WordWrap affects Undo/Redo? Pin
εїзεїзεїз22-Aug-09 20:17
εїзεїзεїз22-Aug-09 20:17 
GeneralRe: In RichTextBox, changing WordWrap affects Undo/Redo? Pin
εїзεїзεїз22-Aug-09 20:22
εїзεїзεїз22-Aug-09 20:22 
GeneralRe: In RichTextBox, changing WordWrap affects Undo/Redo? Pin
Alan Burkhart23-Aug-09 5:11
Alan Burkhart23-Aug-09 5:11 
GeneralRe: In RichTextBox, changing WordWrap affects Undo/Redo? Pin
Alan N23-Aug-09 13:02
Alan N23-Aug-09 13:02 
GeneralRe: In RichTextBox, changing WordWrap affects Undo/Redo? Pin
Alan Burkhart23-Aug-09 14:31
Alan Burkhart23-Aug-09 14:31 
QuestionSmall problem pasting text Pin
Alan Burkhart21-Aug-09 18:06
Alan Burkhart21-Aug-09 18:06 
AnswerRe: Small problem pasting text Pin
εїзεїзεїз21-Aug-09 21:20
εїзεїзεїз21-Aug-09 21:20 
AnswerRe: Small problem pasting text Pin
Luc Pattyn22-Aug-09 0:28
sitebuilderLuc Pattyn22-Aug-09 0:28 
GeneralRe: Small problem pasting text Pin
Alan Burkhart22-Aug-09 2:25
Alan Burkhart22-Aug-09 2:25 
QuestionChanging DateTimePicker MinDateTime to something other than 01/01/1753 Pin
codeprojectalanr21-Aug-09 12:10
codeprojectalanr21-Aug-09 12:10 
AnswerRe: Changing DateTimePicker MinDateTime to something other than 01/01/1753 Pin
Henry Minute21-Aug-09 12:48
Henry Minute21-Aug-09 12:48 
GeneralRe: Changing DateTimePicker MinDateTime to something other than 01/01/1753 Pin
codeprojectalanr22-Aug-09 3:22
codeprojectalanr22-Aug-09 3:22 
GeneralRe: Changing DateTimePicker MinDateTime to something other than 01/01/1753 Pin
Henry Minute22-Aug-09 6:00
Henry Minute22-Aug-09 6:00 
GeneralRe: Changing DateTimePicker MinDateTime to something other than 01/01/1753 Pin
Todd Carnes9-Apr-10 14:20
Todd Carnes9-Apr-10 14:20 
QuestionRemove border of group box Pin
Aman Bhullar20-Aug-09 3:19
Aman Bhullar20-Aug-09 3:19 
AnswerRe: Remove border of group box Pin
Luc Pattyn20-Aug-09 3:28
sitebuilderLuc Pattyn20-Aug-09 3:28 
AnswerRe: Remove border of group box Pin
Dave Kreskowiak20-Aug-09 3:33
mveDave Kreskowiak20-Aug-09 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.