Form based editing ?

N

___Newbie___

Hello,

What is the best way to implement a form based editing?
The user would select first from a list control (highlighted selection) ?
e.g. through a listbox or datagrid. Then, select from buttons: [New],
[Edit], [Delete]. When editButton is clicked, a form will be displayed for
editing.
How would I populate the form edit window? By setting each field. e.g.
fieldA.text = "value", fieldB.text, etc. Or is there something like DataGrid
control displayed as form ?
Thanks for any help.
 
B

Bruce Wood

If I understand you correctly, you want to build a classic maintenance
form, where the user can edit the individual fields of the selected
item.

If this is so, then in answer to your question, no there is (currently)
no way to auto-populate the individual controls that hold the value of
each field. You have to populate them one by one, as you pointed out.

That said, you should encapsulate this process by having the form
and/or panel that contains the individual controls export a property
for the business object being edited / created.

Setting the property stores the business object in the form / panel and
copies the properties of the business object into the individual
controls.

Getting the property builds a new business object from the contents of
the individual controls.

That way, callers to your form can just create a new form and say
something like:

form1.Customer = ...

and all of the fields will be set up. SImilarly, when the user clicks
"OK", the caller can say:

Customer changedCustomer = form1.Customer;

to get the changes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top