C
C#9mo ago
Spore355

✅ Creating a Search Bar for an app in Visual Studios

Hey, would it be possible for anyone to offer me some help with making a search bar for an app I am making? It is for a school project, and I am struggling to create the search bar. Any help at all would be greatly appreciated.
22 Replies
Angius
Angius9mo ago
What's the project? Web? Desktop? Mobile? What will you be searching? Files? Database?
Spore355
Spore355OP9mo ago
It is a desktop app, and I am searching through a database, although I believe I already have tables with the contents that I want to search through.
Angius
Angius9mo ago
Make a text field, then, and a button On button press, take the contents of the field and query the database
Spore355
Spore355OP9mo ago
I'll be honest, I am a little bit out of my depth on this project, do you think you could walk me through it on a VC while I share my screen?
Angius
Angius9mo ago
SELECT p.Id, p.Title FROM Posts p WHERE p.Title LIKE %:query% LIMIT 10 The query would be something like that Can't really join VC right now, sorry
Spore355
Spore355OP9mo ago
What does this part mean? %:query% LIMIT 10 That's ok, I will try my best to go off of your advice.
Angius
Angius9mo ago
:query would be the parameter to your query % is a placeholder meaning "anything"
Spore355
Spore355OP9mo ago
Meaning that anything can be passed through as a parameter?
Angius
Angius9mo ago
So %cat% would match catastrophe, cat, copycat and vocational
Spore355
Spore355OP9mo ago
Oh that is exactly what I am looking for. Thank you.
Angius
Angius9mo ago
Well, in this case, the parameter should probably be a string
Spore355
Spore355OP9mo ago
Yes. How do I make a text field?
Spore355
Spore355OP9mo ago
Currently, I have just been using data tables and datagridviews.
Angius
Angius9mo ago
Depends on the UI framework you use Winforms? WPF? Avalonia?
Spore355
Spore355OP9mo ago
Which have all been snapped to the left I think Winforms, it was a while ago when I first started the project, and I had a large break I did consider Avalonia, but never did anything with it Is there a way for me to check what I am using?
Angius
Angius9mo ago
Take a look at the code for the main window If it's a Form, it's Winforms If it's a Window it's WPF
Spore355
Spore355OP9mo ago
It's Form So Winforms
Angius
Angius9mo ago
Yep You should be able to just drag a text input and a button from the toolbox in the designer, then And drop it wherever you need it to be
Spore355
Spore355OP9mo ago
Anytime I drag anything into the designer it seems to mess my program up Plus, it's tricky to scale with my datatable on the left side as that expands to fit the text inside of it
Angius
Angius9mo ago
https://learn.microsoft.com/en-us/dotnet/desktop/winforms/controls/layout?view=netdesktop-8.0 You can use containers and stuff to make the layout how you want it
Spore355
Spore355OP9mo ago
Ok great, thank you
Want results from more Discord servers?
Add your server