Dr ZIZO
Dr ZIZO

Reputation: 333

Display Data in form

I have Clients table with Client_Name , Client_Address and Client_Phone columns.

And I have a form Client Manager to EDIT/DELETE the clients.

How can I display the Clients table in the form and enable user to manage (EDIT/DELETE) it ?

I know one way to do this is DataGridView But it doesn't fulfill my needs.

I want something like this : table

I have done this before in php/mysql , like this :

   <table>
   <tr><td>Client Name</td><td>Client Address</td><td>Client  Phone</td><td> EDIT </td><td> DELETE</td></tr>
<?php
foreach ($clients->result_array() as $key)
{
 echo "<tr>";
 echo "<td>".$key['Client_Name']."</td>";
 echo "<td>".$key['Client_Address']."</td>";
 echo "<td>".$key['Client_Phone']."</td>";
 echo "<td><a href='edit.php?id=".$key['id']."'>Edit</a></td>";
 echo "<td><a href='delete.php?id".$key['id']."'>Delete</a></td>";
 echo "</tr>";
}

How to do something like this in c# ?

Upvotes: 1

Views: 116

Answers (1)

Reza Aghaei
Reza Aghaei

Reputation: 125197

In windows Forms you can use:

  • DataGridView for show data in a grid.
  • ToolStrip as a command bar above grid

Editable


Using Toolstrip for add, delete and save operations. Edit will be done in grid.

  • Add Button: adds a new record at the end of grid.
  • Delete Button: removes selected record from grid.
  • Save Button: saves changes including add, edit and deletes.

enter image description here

Non-Editable


Using Toolstrip for add, delete and edit operations. add and edit usually will be done in separate form, delete will be done using after a MessageBox for confirm delete.

  • Add Button: Shows a Form and you create new entity in that form and Save it in database and then after closing that form, you reload data to your grid.
  • Delete Button: Shows a MessageBox to confirm deletion and after you clicked on yes/ok and MessageBox closed, you delete data and reload data to grid.
  • Edit Button: Pass data to a Form and shows the form and you edit you edit entity in that form and Save it in database, and then after closing that form you reload data to your grid.
  • There is no need to Save Button.

enter image description here

Screen shot of Add Form, Edit Form is like Add Form and show entity data in controls:

enter image description here

Upvotes: 1

Related Questions