Hi, all, I've stumbled upon a behavior of the .NET RichTextBox that I think is a bug, and I wanted somebody to do a sanity check before I report this to MS. Below is a code listing. It displays a form with a RichTextBox control in it. Ctrl++ and Ctrl+- increase/decrease zoom. Space and Backspace keys change content of the text box. Currently, zoom step is 0.5. Notice that when zoom factor is 2.0 (you can make it that by pressing Ctrl++ twice), the text box doesn't retain the zoom factor when its content changes. When you uncomment MessageBox statement in DisplayText (uses Clear() method of the text box class) method, you can more glimpse of the weird behavior. It is actually different with the MessageBox there. Increase zoom to 2.0 by pressing Ctrl++ twice and then press Space or Backspace repeatedly and notice zoom factor change from 2.0 to 1.0 to 2.0 to 1.0, … After that, change the zoom step to, say, 0.3 (zoom factor doesn't become 2.0 with this step), and notice that the box behaves as expected (the zoom factor remains as set). Is this a bug or reflection of my wrong expectations? Thanks ---------------------------------- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace BugInZoomFactor { /// /// Summary description for Form2. /// public class BugInZoomFactorForm : System.Windows.Forms.Form { private System.Windows.Forms.RichTextBox richTextBox1; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; private float zoomFactor = 1.0f; private float zoomStep = 0.5f; public BugInZoomFactorForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.KeyPreview = true; DisplayText("Initial text"); } private void DisplayText(string text) { richTextBox1.Clear(); richTextBox1.ZoomFactor = zoomFactor; //MessageBox.Show("control's zoom factor is " + richTextBox1. ZoomFactor.ToString()); richTextBox1.AppendText(text); } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows F
R
Roman R
@Roman R
Posts
-
Unexpected (buggy?) behavior of RichTextBox when ZoomFactor is 2.0 -
Need a multiline listview Windows Forms controlThanks. I will check it out. This seems to be what I need. No source code, though. :(
-
Need a multiline listview Windows Forms controlTrue, I am looking for a free one, but I've saved your link for time when I will develop software for sale. Thanks
-
Need a multiline listview Windows Forms controlI need a ListView control.
-
Need a multiline listview Windows Forms controlThanks, but I searched first and then asked for help.
-
Need a multiline listview Windows Forms controlCould anyone point me to a multiline (text of an item can be displayed on multiple lines) listview Windows Forms control? Thanks
-
No ConfidenceSoviet Union used to have an even larger border before it split up, I believe, but was able to have it protected.