Predictive Search within C# Windows Form?
-
I can export the database part numbers into an array. I want to be able to search that array with predictive search. a good example is www.yahoo.com's search engine text box on the front page. How do i achieve this within a windows form and not in a web project. I've searched around for this but have not found much of anything useful. Thank you guys! Patrick!
-
I can export the database part numbers into an array. I want to be able to search that array with predictive search. a good example is www.yahoo.com's search engine text box on the front page. How do i achieve this within a windows form and not in a web project. I've searched around for this but have not found much of anything useful. Thank you guys! Patrick!
What have you been able to do so far?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
I can export the database part numbers into an array. I want to be able to search that array with predictive search. a good example is www.yahoo.com's search engine text box on the front page. How do i achieve this within a windows form and not in a web project. I've searched around for this but have not found much of anything useful. Thank you guys! Patrick!
Have you tried using the Custom AutoComplete function of the textbox?
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
-
Have you tried using the Custom AutoComplete function of the textbox?
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
I did not even realize that the text box had autocomplete already. Thanks man! ran through my datagrid to make the textbox have a custom data source, but that took an awful long time to initialize due to 16K records. Any recommendations instead of a loop going through the datagridview of the first column then adding to the custom text box datasource for 16K records? Thank you sincerely once again!
-
I did not even realize that the text box had autocomplete already. Thanks man! ran through my datagrid to make the textbox have a custom data source, but that took an awful long time to initialize due to 16K records. Any recommendations instead of a loop going through the datagridview of the first column then adding to the custom text box datasource for 16K records? Thank you sincerely once again!
I don't know if this is the proper way to do it but I usually do it this way. 1. Create a Datatable 2. Fill the Datatable with the column of interest (Select COLUMN from Table) 3. Use a foreach loop to go thru each row 4. Use a StringBuilder to append those rows 5. Attatch the StringBuilder to the textbox. I usually doesn't any encounter a very long initialization time using this method. I used it in one of my OPAC projects.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
-
I don't know if this is the proper way to do it but I usually do it this way. 1. Create a Datatable 2. Fill the Datatable with the column of interest (Select COLUMN from Table) 3. Use a foreach loop to go thru each row 4. Use a StringBuilder to append those rows 5. Attatch the StringBuilder to the textbox. I usually doesn't any encounter a very long initialization time using this method. I used it in one of my OPAC projects.
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
Below is the code i used for the autocomplete text box to search through the records and focus on the record closest matched which is scrolled to in the list automatically. What do you think!? ---- private void txtSearchbyPN_KeyUp(object sender, KeyEventArgs e) { string searchStr = txtSearchbyPN.Text.ToString(); int searchLen = txtSearchbyPN.Text.Length; for (int i = 0; i < cachedPartNumbers.Length; i++) { if (cachedPartNumbers[i].Length >= searchLen) { if (searchStr.Equals(((cachedPartNumbers[i].ToString()).Substring(0, searchLen)))) { locationInArray = i; break; } } } dgMainForm.CurrentCell = dgMainForm.Rows[locationInArray].Cells[0]; }
-
Below is the code i used for the autocomplete text box to search through the records and focus on the record closest matched which is scrolled to in the list automatically. What do you think!? ---- private void txtSearchbyPN_KeyUp(object sender, KeyEventArgs e) { string searchStr = txtSearchbyPN.Text.ToString(); int searchLen = txtSearchbyPN.Text.Length; for (int i = 0; i < cachedPartNumbers.Length; i++) { if (cachedPartNumbers[i].Length >= searchLen) { if (searchStr.Equals(((cachedPartNumbers[i].ToString()).Substring(0, searchLen)))) { locationInArray = i; break; } } } dgMainForm.CurrentCell = dgMainForm.Rows[locationInArray].Cells[0]; }
Hi, Two comments: 1. I suggest you have a look at String.StartsWith() 2. You might want to store the results of cachedPartNumbers[i].ToString() rather than calling it all the time :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|