Text in rich textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
How can I automatically adjust height of my rich textbox so it always shows the whole text without using scrollbars

Chris
Sweden
 
Chris said:
Hi,
How can I automatically adjust height of my rich textbox so it always
shows the whole text without using scrollbars?
Chris,
Sweden

I think you need to calculate the height of a single line instead of the
height of the font. When the total height is larger than the rich text box,
you need to set a smaller font. You have to do the calculation in
TextChanged event.
 
Thanks all, a combination of the code in both replies fixed my problem. I wonder why the treeview wasn't designed to select the node that you clicked on automatically? hmm. Thanks again!

nntp://news.microsoft.com/microsoft.public.dotnet.framework.windowsforms/<#mO#[email protected]>

* "Jonathan Miller said:
I'm using vb.net and the treeview control. I have a created a context
menu with a few items on it and set the context menu property of my
treeview control to my context menu. Here is the problem: If I
right-click on a node that is not currently the selectednode the
following happens: The right-clicked node becomes
highlighted. (correct) The context menu appears on top of the
right-clicked node. (correct) The selectedNode property of the treeview
is last selected node, not the right-clicked node! (not good!).

Quick and (very) Dirty:

\\\
Private Sub TreeView1_MouseUp( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs _
) Handles TreeView1.MouseUp
If e.Button = MouseButtons.Right Then
Dim n As TreeNode = Me.TreeView1.GetNodeAt(e.X, e.Y)
If Not n Is Nothing Then
Me.TreeView1.SelectedNode = n
Me.MenuItem1.Text = n.Text
Else
Me.MenuItem1.Text = "(no item selected)"
End If
Me.ContextMenu1.Show(Me.TreeView1, New Point(e.X, e.Y))
End If
End Sub
///
 
Back
Top