Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Experts*
Posted

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

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted
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]

  • *Experts*
Posted

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.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...