Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a form at cursor location in a textbox 4

Status
Not open for further replies.

ZmrAbdulla

Technical User
Apr 22, 2003
4,364
AE
Is that possible to open small form at the current cursor location of a multiline=true textbox?
I am trying to imitate the intelliscence of the vb code window.
It was possible with vb6 API calls. No idea how with .net.

Thanks

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
I don't know why it is not working for me. There is no difference with this code too.

I didn't get time to check with Sharp Develope. Let me see.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
earthandfire, It is working fine with Sharp Develope.
I need to investigate more about my express edition installation.

Thanks to all of you

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
Zameer, I hope to be able to post a bit more here later today. Glad you've got it working, but I don't understand why it doesn't work when its in 2005 Express.

[vampire][bat]
 
Hello, new to this but experience in programming, Think the approach you should take is keeping focus on textbox and not listbox, otherwise the solution you have will not work if "." is in the middle of a group of text. If you would like I could post my solution I'm writing an intelisense control now.
 
I'm not sure I understand - what difference does it make on whether you show a TextBox or a ListBox once a "." is pressed?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
What I mean is keep focus on the TextBox as in the applications focus property. I ended up creating a quick and dirty control to handle this for me. Just create a class and paste this code in, then you can reuse the control anywhere. Sorry no comments in code, feel free to clean up and add comments if you wish.

Option Strict Off

Public Class IntelisenseListBox
Inherits ListBox

Private Sub InitializeComponent()
Me.SuspendLayout()
'
'Intelisense
'
Me.Visible = False
Me.ResumeLayout(False)

End Sub

Public Sub New()
Me.Visible = False
End Sub

Private WithEvents txtParentTextBox As RichTextBox

Public Property ParentTextBox() As RichTextBox
Get
Return txtParentTextBox
End Get
Set(ByVal Value As RichTextBox)
txtParentTextBox = Value
End Set
End Property

Private Sub txtParentTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtParentTextBox.KeyDown
If Me.Visible = True Then
Select Case e.KeyCode
Case Keys.Enter
e.Handled = True
End Select
End If

End Sub

Private Sub txtParentTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtParentTextBox.KeyPress
If e.KeyChar = CChar(".") Then
Dim curPoint As Point = txtParentTextBox.GetPositionFromCharIndex(txtParentTextBox.SelectionStart)
curPoint.Offset(txtParentTextBox.Left, txtParentTextBox.Top + txtParentTextBox.SelectionFont.Height)
Me.Location = curPoint
Me.Visible = True
ElseIf Me.Visible Then
If e.KeyChar = Convert.ToChar(Keys.Escape) Then
Me.Visible = False
ElseIf e.KeyChar = Convert.ToChar(Keys.Enter) Then
If Me.SelectedIndex > -1 Then
SendKeys.Send(Me.Text)
End If
Me.SelectedIndex = -1
Me.Visible = False
e.Handled = True
ElseIf e.KeyChar = Convert.ToChar(Keys.Space) Then
If Me.SelectedIndex > -1 Then
SendKeys.Send(Me.Text & " ")
End If
Me.SelectedIndex = -1
Me.Visible = False
e.Handled = True
End If
End If

End Sub


Private Sub IntelisenseListBox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
txtParentTextBox.Focus()
End Sub

Private Sub txtParentTextBox_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtParentTextBox.KeyUp
If Me.Visible Then
If e.KeyCode = Keys.Up Then
Try
Me.SelectedIndex -= 1
Me.SelectedItem.EnsureVisible()
Catch
End Try
ElseIf e.KeyCode = Keys.Down Then
Try
Me.SelectedIndex += 1
Me.SelectedItem.EnsureVisible()
Catch
End Try
End If
End If


End Sub
End Class


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top