Click here to Skip to main content
15,888,005 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Need help with search option in Windows form.

What I have tried:

I am trying to figure out how to add a search feature to a windows form. I have a combobox with three options. Code, Name, City. When you choose one, I need another box to open to enter search criteria and then return values in a grid format.  I have seen examples on the getting the grid setup, but cannot figure out the search part. Any ideas / examples would be appreciated. 
Posted
Updated 22-May-19 19:51pm
v2
Comments
F-ES Sitecore 22-May-19 14:19pm    
There isn't enough information to help. How you search depends on where the data is. Is it in files? One file? XML? A database? The registry? The internet?
MIDCOPC 22-May-19 14:47pm    
Data is in an MySQL database.
ZurdoDev 22-May-19 15:17pm    
Where are you stuck?
MIDCOPC 22-May-19 15:34pm    
I don't know where start to create the search options. I have the combobox working.

// Create the Search List
private void LoadSearchList()
{
List<string> SearchList = new List<string>
{
"Code",
"Name",
"City"
};

AccountSearchListValue.DataSource = SearchList;

Here is a basic article on how to connect and query MySQL database with the SELECT command:
Connect C# to MySQL[^]
More information about SQL here: SQL SELECT Statement[^]
 
Share this answer
 
Comments
MIDCOPC 22-May-19 15:53pm    
Thank Rick. I am already connected to the database.
I was able to figure this out.
 
Share this answer
 
Hi,

suppose you have combobox1 with values 'Code', 'Name', 'City' and Textbox2/Combobox2 for enter searchValue.


on TextBox2/ComboBox2 TextChange event you can check for selected combobox1 value like Code or other and according you can query in DataBase for possible values to show in grid.


Hope this will help you.

**Mark as Answer if found useful.

Regards,
Jatinath
 
Share this answer
 
Comments
Jatinath 27-May-19 9:22am    
why my answer is downvoted? if I have tried to answer and it near or related to asked questions then why?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900