Hello! I'm a programming student and a newbie in forums. :)

How can I search for a data in listview from fist form using my second form?

For example, I entered 7 entries to my listview,
and when I press "Search in listview" button, the second form will open.
(My first form contains the listview table
and a button named "Search in listview", while the second form
contains a textbox which I'll type what I want to search,
for example the ID Number, and a button named "Search".)

To shorten my code, I like to use from the System.IO Namespace.
Is it possible to use System.IO? How?
It is frustrating that I can't even find it in Google.

:-/
Help is appreciated. Thank you.

Dani AI

Generated

Short answer: you do not need System.IO to search a ListView from another form. System.IO is the namespace for file and stream I/O (useful when you want to save or load the list to disk) — see the System.IO docs for details: System.IO namespace. Since asked about language, and confirmed VB.NET, below are two practical VB.NET patterns depending on whether this is a WinForms app or an ASP.NET WebForms app.

WinForms pattern (recommended for desktop): open the search form with ShowDialog, expose the typed text as a public property on the search form, then let the main form read that property and locate the item with ListView.FindItemWithText or by iterating items. This keeps UI flow simple and avoids trying to directly manipulate controls on another form instance. See the ListView.FindItemWithText docs if you use that helper: ListView.FindItemWithText.

ASP.NET WebForms pattern: post the search term back to the ListView page (use POST, Session, or a query string for non-sensitive terms) and rebind the data source after filtering (DataView.RowFilter or a LINQ query). Opening a separate page for a search box is fine, but server-side filtering and rebinding is the usual approach. Note: only use System.IO here if you intend to persist data to files; it is not required for inter-page communication.

Recommended Answers

All 2 Replies

That would depend on the language you're working in - VB.NET? C#?

If you'll tell us, we can move this post to the appropriate forum where the experts can help out. :)

Visual Basic .NET

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.