Hello all, I'll do my best to make this as simple as possible to explain.
1. I'm using a WinForm DataGridView.
2. I'm using an auto complete feature that I've coded and I'm trying to add the data that a user has entered in the first column to a generic list.
Here is some of my code:
dataGridView_EditingControlShowing
if (dgvCommands)
{
DataGridViewTextBoxEditingControl te = (DataGridViewTextBoxEditingControl)e.Control;
te.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
te.AutoCompleteSource = AutoCompleteSource.CustomSource;
switch (dgv_Alias.CurrentCell.ColumnIndex)
{
case 0:
te.AutoCompleteCustomSource.Clear();
break;
case 1:
te.AutoCompleteCustomSource.Clear();
te.AutoCompleteCustomSource.AddRange(sCommands);
break;
}
}
else
{ }
This is the code that loads the commands to the sCommands Array List.
private List<string> Commands = new List<string>();
private string[] sCommands;
private bool dgvCommands;
private void AC_LoadCommands()
{
if (File.Exists(@"data/cmds.txt"))
{
StreamReader sr = new StreamReader(@"data/cmds.txt");
string line;
while ((line = sr.ReadLine()) != null)
{
if (!line.Contains("//"))
{
Commands.Add(line);
}
else
{ }
}
sr.Close();
for (int i = 0; i != Commands.Count; i++)
{
sCommands = Commands.ToArray();
}
dgvCommands = true;
}
else
{
MessageBox.Show("Missing File: 'data/cmds.txt'\nAuto Complete cannot function without this file.", "Missing File: 'data/cmds.txt'", MessageBoxButtons.OK, MessageBoxIcon.Error);
dgvCommands = false;
}
And that Method is loaded when the program starts under the Form_Loading Event.
Now I would like to gather the data from the first column and add it to the sCommands string array.
I need to know what events to use and a detailed example of how to go about doing so.
Any help would be greatly appreciated.
Thanks
- Poab9200