mookie Posted February 11, 2005 Posted February 11, 2005 I dont know if i am going about this the right way to start with but regardless, i am finding trouble in trying to find the exact location of the cursor in the textbox Private Function showlvars() Dim vartype As String Select Case SB_Lang.Text Case "KUKA" vartype = KUKALanguage.vartype(RTF.Currentword) Select Case vartype Case "POSITION" lvars.Items.Clear() lvars.Items.Add("X") lvars.Items.Add("Y") lvars.Items.Add("Z") lvars.Items.Add("A") lvars.Items.Add("B") lvars.Items.Add("C") lvars.Items.Add("S") lvars.Items.Add("T") End Select End Select lvars.Location = RTF.Cursor.Position lvars.Focus() lvars.Show() End Function basically in a lot of ways, Im trying to emulate how things work in the vb.net environment as they work the same with the robotic software. but i am trying to use a listbox that will appear after someone enters the text ".". i know i dont want to use the cursor position because it comes up incorrect though. Quote
*Experts* DiverDan Posted February 11, 2005 *Experts* Posted February 11, 2005 Do you mean Dim pt As Point pt.X = ListBox1.PointToClient(Cursor.Current.Position).X pt.Y = ListBox1.PointToClient(Cursor.Current.Position).Y Then use the listboxes Bounds.X and Bounds.Y to see which item the cursor is currently over. Here's a sample with a Listview, the listbox cursor position computations should be same. Private Sub lvwTrays_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lvwTrays.MouseMove Dim pt As Point pt.X = lvwTrays.PointToClient(Cursor.Current.Position).X pt.Y = lvwTrays.PointToClient(Cursor.Current.Position).Y Dim lvwCollection As ListView.ListViewItemCollection = DirectCast(lvwTrays.Items, ListView.ListViewItemCollection) Dim lvwItem As ListViewItem For Each lvwItem In lvwCollection If pt.X >= lvwItem.Bounds.X And pt.X <= lvwItem.Bounds.X + lvwItem.Bounds.Width _ And pt.Y >= lvwItem.Bounds.Y And pt.Y <= lvwItem.Bounds.Y + lvwItem.Bounds.Height Then If Not lvwItem.Selected = True Then lvwItem.Selected = True Else : lvwItem.Selected = False End If Next End Sub Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
mookie Posted February 12, 2005 Author Posted February 12, 2005 Do you mean Dim pt As Point pt.X = ListBox1.PointToClient(Cursor.Current.Position).X pt.Y = ListBox1.PointToClient(Cursor.Current.Position).Y Then use the listboxes Bounds.X and Bounds.Y to see which item the cursor is currently over. Here's a sample with a Listview, the listbox cursor position computations should be same. Private Sub lvwTrays_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lvwTrays.MouseMove Dim pt As Point pt.X = lvwTrays.PointToClient(Cursor.Current.Position).X pt.Y = lvwTrays.PointToClient(Cursor.Current.Position).Y Dim lvwCollection As ListView.ListViewItemCollection = DirectCast(lvwTrays.Items, ListView.ListViewItemCollection) Dim lvwItem As ListViewItem For Each lvwItem In lvwCollection If pt.X >= lvwItem.Bounds.X And pt.X <= lvwItem.Bounds.X + lvwItem.Bounds.Width _ And pt.Y >= lvwItem.Bounds.Y And pt.Y <= lvwItem.Bounds.Y + lvwItem.Bounds.Height Then If Not lvwItem.Selected = True Then lvwItem.Selected = True Else : lvwItem.Selected = False End If Next End Sub actually no. im actually looking for the caret position in the textbox. I dont know why i have the hardest time finding these things out. alot of the features that im putting into my program are normally found in most of the applications i use and i dont understand why its not built right in [/soapbox] Quote
*Experts* DiverDan Posted February 12, 2005 *Experts* Posted February 12, 2005 I think you'll have an eaiser time finding things out here if you are more specific. looking at you code....Is it a textbox or a richtext box? now that we know that you want the caret position I think the boxes SelectionStart properity should help you out. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
mookie Posted February 16, 2005 Author Posted February 16, 2005 i am using the rich textbox control. I am able to find the caret position within the screen now, but what im doing is using a listbox to attempt to simulate intellisense. the problem is that i need to give it an x,y coordinate in order to get it to show up correctly. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.