Solved

Move ListBox into RTF, 1 line under.

Posted on 1998-11-02
2
172 Views
Last Modified: 2010-04-30
Fellow VB Programmers,

I am using the RichTextBox control and would like to know
how to move the a ListBox underneath the current line,
like in VB when you dim a value as, a ComboBox or ListBox appears.

For the sake of this question,
Please insert the RTF Control and a ListBox onto a form.
Let the Listbox.Visisble = False and insert the Following code
into your sample...

Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)

Select Case Chr$(KeyAscii)
case "!"
      List1.Visible = True
      ' And the Code to move it here...
case else
end select
end sub

When you press the ! key, it will show you the ListBox.

Now, in order to properly answer this Question,
have the ListBox popup right underneath your current position
in the RichTextBox control. Left & Top.

Thank you.
0
Comment
Question by:s_mccolgan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 2

Expert Comment

by:Poddy
ID: 1442796
Have you considered using the right-click context menu?
0
 
LVL 2

Accepted Solution

by:
Poddy earned 200 total points
ID: 1442797
Private Type POINTAPI
        x As Long
        y As Long
End Type

Private Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long

  Dim ptX As POINTAPI
  Dim lngRet As Long  
    If KeyAscii = 33 Then
      List1.Visible = True
      lngRet = GetCaretPos(ptX)
      List1.Top = Screen.TwipsPerPixelY * ptX.y + RichTextBox1.Top
      List1.Left = Screen.TwipsPerPixelX * ptX.x + RichTextBox1.Left
    end if
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 65
Excel Automation VBA 19 116
VBA - If Bookmark = "XXBOOKMARKXX" then 15 66
VB script to continue despite error 2 77
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question