Am trying to make a contextMenuStrip to scroll to a certain position on a RichTextBox on the selected text. When you use a small file on the RichTextBox, it is working perfectly... But when you use a large file, the Menustrip cannot scroll to that position with the help of the scrollbars on the RichTextBox. How can I solve this problem from the code here:
Where word is selected on:
Code:ContextMenuStrip1.Show(RichTextBox1, RichTextBox1.GetPositionFromCharIndex(RichTextBox1.SelectionStart + RichTextBox1.SelectionLength))
Show the Menu under the selected text on the RichTextBox:
Code:Private Sub ContextMenuStrip1_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening Try With RichTextBox1 Dim pt As Point = Me.PointToClient(.PointToScreen(.GetPositionFromCharIndex(.SelectionStart))) pt.Y += .Font.Height ' * Assuming all text use same Font/Height! ContextMenuStrip1.Show(PointToScreen(pt)) End With Catch ex As Exception MessageBox.Show(ex.Message, "Exception Window", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Exit Sub End Sub




Reply With Quote
