In my Tic Tac Toe game I ask the players for their names and I ask them whether they want it to be saved. The next time they start the game I want the InputBox
to display some sort of auto complete or IntelliSense
to appear.
QUESTION :
How do I get auto complete or IntelliSense
to appear on InputBox
Just for in case. I included :
using Microsoft.VisualBasic;
in my code.
In order to use an "Intellisense" by which I'm guessing you mean "AutoComplete", you can simply set up a TextBox
and assign its AutoComplete...
properties. The ones you'll need in particular are:
DataSet
or any kind of database access, if you don't want to go that way.edit
As an example:
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoCompleteStringCollection items = new AutoCompleteStringCollection();
items.Add("Save");
items.Add("Don't Save");
textBox1.AutoCompleteCustomSource = items;
edit 2
As requested, here is how to read a text file line by line and use the data within as the custom source for your AutoComplete
string line = "";
AutoCompleteStringCollection items = new AutoCompleteStringCollection();
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader("YOURFILE.txt");
while((line = file.ReadLine()) != null)
{
if(!String.IsNullOrEmpty(line))
{
items.Add(line);
}
}
file.Close();
Hope this helps!