lets say i design a form on a windows form where i can write down customer info, for example, now, how can i save that so that when opened, by double clicking, i can view that certain record and maybe even edit it on the spot?
if anyone can answer that i'd appreciate it, or maybe even show me an example!
thanks in advance.

Dani AI

Generated

As asked about saving a WinForms customer form and opening/editing by double‑click, there are two practical patterns: a central data store (best for many records, searching, or multi‑user) or file‑per‑record (simpler for a single user). raised the file option and suggested a database; both are valid. The notes below give concrete, reliable ways to implement each and practical cautions.

If using a database: design a table with a stable primary key and a last‑modified timestamp. Put DB access behind a small data layer (parameterized commands or an ORM) and always validate input and use transactions for updates. Common UI pattern: show records in a DataGridView bound to a BindingSource; on row double‑click open an edit dialog that loads the record by id, lets the user edit, then runs an UPDATE and refreshes the grid. Example cell double‑click pattern:

Private Sub customersGrid_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles customersGrid.CellDoubleClick
    If e.RowIndex < 0 Then Return
    Dim id As Integer = Convert.ToInt32(customersGrid.Rows(e.RowIndex).Cells("CustomerId").Value)
    Using frm As New EditCustomerForm(id)
        If frm.ShowDialog() = DialogResult.OK Then LoadCustomers()
    End Using
End Sub

If using files: serialize each record (JSON or XML) and keep an ID inside the file or the filename. To allow double‑clicking a file in Explorer, register a custom extension in your installer and read the file path from the command line when the app starts; pass it into the main form and load/lock the file for editing. Example startup handling:

Module Program
    <STAThread()>
    Sub Main()
        Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)
        Dim args = Environment.GetCommandLineArgs()
        If args.Length > 1 Then Application.Run(New MainForm(args(1))) Else Application.Run(New MainForm())
    End Sub
End Module

Cautions: prefer a DB (SQLite/LocalDB) if you need concurrency, full‑text queries, or backups. Always use parameterized SQL or an ORM to avoid injection, validate user input, and make saves atomic (write temp then rename) to avoid corruption.

Recommended Answers

All 2 Replies

Member Avatar for Member #46692

would this record happened to be saved as a text file?

just,
save the customer info in the database-using insert command& access the records by using "select query"..
This is what u meant.....

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.