C
Chinnu.M
Guest
I am using RichTextBox control to find the height of the RTF text based on it width and proceed to create a vector images. The code I am using is working fine without any issues in .NET Framework 4.6 and less. But after updating .NET Framework to 4.7, the ContentResizedEvent is not firing, So that I could not get the exact height of the RTF. Any one kindly help me to resolve this issue. The code I am using below.
float height = 0;
private float GetRichTextBoxHeight()
{
RichTextBox richTextBox = new RichTextBox();
richTextBox.AutoSize = true;
richTextBox.AcceptsTab = true;
richTextBox.DetectUrls = false;
richTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
richTextBox.BackColor = Color.FromArgb(255, Color.White);
richTextBox.Rtf = string.Empty;
richTextBox.ScrollBars = RichTextBoxScrollBars.None;
richTextBox.ContentsResized += new ContentsResizedEventHandler(ContentsResized);
richTextBox.Bounds = new System.Drawing.Rectangle(0, 0, (int)556, 1);
richTextBox.Rtf = "//RTF text";
return height;
}
private void ContentsResized(object sender, ContentsResizedEventArgs e)
{
height = e.NewRectangle.Height;
}
Continue reading...
float height = 0;
private float GetRichTextBoxHeight()
{
RichTextBox richTextBox = new RichTextBox();
richTextBox.AutoSize = true;
richTextBox.AcceptsTab = true;
richTextBox.DetectUrls = false;
richTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
richTextBox.BackColor = Color.FromArgb(255, Color.White);
richTextBox.Rtf = string.Empty;
richTextBox.ScrollBars = RichTextBoxScrollBars.None;
richTextBox.ContentsResized += new ContentsResizedEventHandler(ContentsResized);
richTextBox.Bounds = new System.Drawing.Rectangle(0, 0, (int)556, 1);
richTextBox.Rtf = "//RTF text";
return height;
}
private void ContentsResized(object sender, ContentsResizedEventArgs e)
{
height = e.NewRectangle.Height;
}
Continue reading...