473,698 Members | 2,198 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Searching text in datagridview

Hi

Well what i'm trying to do is search text in a datagridview, i've seen
similar code around in other posts or forums, i'm implementing this by using
a Textbox, and the code in the TextChanged event, so when the user keeps
typing, the datagridview must refresh itself showing only the results that
contain the text written so far.

I've seen this in two ways.....checki ng the text in the rows one by one....
and the other way is using a query, like..

string query = "SELECT * FROM Table WHERE title=" + txtSearch.Text;

and after that execute the query and update the datagridview, something like
that.... but which way to do it has better performance??

mmm another thing, the table has less than 1000 rows.. so maybe it won't
even be a significant difference in time, but still, i'd like to know other
opinions about which way results in a faster, better and easier way to do it
:)

Thanks in advance

--
Any reply is helpful for someone

VBA
Jan 14 '07 #1
1 3301
The question isn't really which option will make your code run faster;
you want to search the data-grid by enumerating the rows and avoid
querying the database over and over to keep pressure off the database.

Also, you probably want to look into "delayed event handling" so that
you don't check a thousand rows after every keystroke.

Jan 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4983
by: saravanan_article | last post by:
Hi Team, This is saravanan i am new to C#.. I am using VS2005 for my windows based application.. I am using DataGridView to show the values.. What i want is i want to display the text in the rowheaders of the DataGridview and I want to enable the tooltip in the cells. Thanks in advance Any help or suggesstion is appreciated
3
7376
by: Leszek | last post by:
Hello! Is there any possibility to load a datagridview from a text file? I have *.tsv file with performance counters and I'm trying to create a webpage (or Windows application), that will show charts etc. I don't know how to connect text file and datagridview. I didn't find any datasource that reads from .tsv file. First row in file will be names a columns. Other rows will be a data. Maybe someone show me an example?
4
8631
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone tell me if this is even possible, and if so, how to do it? If this is completely impossible, how would you suggest going about sorting a ComboBox wherein the text displayed in the column is the client's name, and the underlying value is an ID? ...
7
1731
by: =?Utf-8?B?aWxy?= | last post by:
Hi I have a table in an sql database that contains data that has been encrypted using the DPAPI. What I am trying to achieve is to bind several controls on a vb 2005 windows form to those fields but display the decrypted data in the controls instead of the encrypted data. I also want to use a binding navigator to scroll through the records and to add/delete records. I don't have a problem with the encryption/decryption but am...
2
17191
by: Steve Richter | last post by:
I set the Text of a DataGridView control expecting this text to be displayed at the top of the control, as the grid title. But the text does not display. How do I display title text above the column heading of a DataGridView? thanks, DataGridView mGrid1 ; mGrid1 = new DataGridView();
0
1102
by: Robert Bravery | last post by:
Hi all, I am looking for a way to create partial serching of a datagridview. SO that as a user would type in a textbox, the position of the row pointer in the grid would change incrementaly as the user types so that (searing in 'name' column) if they type "B" the pointer would dind the start of names beginnig with 'B', then type 'o', and the pointer moves to the start of 'Bo' and so on. Can some one point me in the right direction.
2
1430
by: =?Utf-8?B?VGVycnk=?= | last post by:
I am implementing an 'incremental search', where as the user types into a textbox, a datagridview's current position is updated to match the first record that contains what the user has typed so far. In this particular case, I am searching the 'CompanyName' column of the underlying dataview, which of course is sorted by this column. I have noticed that company names like "U-Freight" and "U-Haul" appear after company names like "UBS" and...
2
4639
by: TG | last post by:
Hi! I am trying to export only the visible columns from a datagridview in my windows form in VB 2008. Should't it be no comma after the first row where the headers are? Also should there be a comma at the last row?
1
1882
by: gobblegob | last post by:
Hello Folks, I am searching a XML file for <Asset_Number> and then adding all children to DataGridView1, i can search but i dont know how to add item to the DataGridView Also my datagridview columns are created from a txt file this is what i have..... this is my XML
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3051
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.