473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Autocompletion on A RichTextBox

My code is working fine when I get the suggestions from the ListView when I click them. The problem is if I type "a" and want "and" as my suggestion from the ListView, it gives me an output like this: aand

How can I solve this error from this code here:



Expand|Select|Wrap|Line Numbers
  1.     Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles RichTextBox1.KeyDown
  2.  
  3.         If e.KeyCode = Keys.Tab And ListView1.Visible Then
  4.             RichTextBox1.SelectedText = Mid(ListView1.FocusedItem.Text, wordParts.Length + 1, ListView1.FocusedItem.ToString - wordParts.Length)
  5.             e.SuppressKeyPress = True
  6.             ListView1.Visible = False
  7.  
  8.         ElseIf e.KeyCode = Keys.Tab And Not ListView1.Visible Then
  9.             RichTextBox1.SelectedText = ""
  10.             e.SuppressKeyPress = True
  11.  
  12.         ElseIf e.KeyCode = Keys.Up And ListView1.Visible Then
  13.  
  14.             If ListView1.SelectedIndices.Count <> 0 Then
  15.  
  16.                 ListView1.GetItemAt(ListView1.SelectedIndices.Count - 1, True)
  17.             End If
  18.             e.SuppressKeyPress = True
  19.  
  20.         ElseIf e.KeyCode = Keys.Down And ListView1.Visible Then
  21.  
  22.             If ListView1.SelectedIndices.Count <> ListView1.Items.Count - 1 Then
  23.  
  24.                 ListView1.GetItemAt(ListView1.SelectedIndices.Count + 1, True)
  25.             End If
  26.             e.SuppressKeyPress = True
  27.  
  28.         ElseIf e.KeyCode = Keys.Left And ListView1.Visible Then
  29.             ListView1.Visible = False
  30.  
  31.         ElseIf e.KeyCode = Keys.Right And ListView1.Visible Then
  32.             ListView1.Visible = False
  33.  
  34.  
  35.         End If
  36.     End Sub
Nov 25 '15 #1
0 1115

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: MS | last post by:
Hi everyone, I have moved to a new installation of Visual Studio 2003 (using C#), and I no longer have the autocompletion feature inside the command window. I have been all through the options...
0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
3
by: kangoo | last post by:
Hi, I'm trying to remove the last charater in a richTextBox. I though richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but it does nothing (eg richTextBox.Text += "some new...
12
by: M O J O | last post by:
Hi, If I inside a thread creates a RichTextBox and only use this inside the thread, will there be any thread problems? I need to convert between Text and RTF inside a thread. Thanks!! M...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
0
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
0
by: cie | last post by:
Hi, I'm having problem with data integration in my program, so I want to give restriction that only data from autocompletion (like in System.Windows.TextBox) which is got from another table can be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.