Select from a List to Edit

G

Guest

I'm new to WindowsForms, but have done a good deal of work with ASP.NET. What
I thought would be a simple task because it is in ASP.NET, I've realized
isn't in Windows Forms.

I'm trying to create a quick way of displaying a list of rows from a
database table that a user can scroll and allows the user to select one to
edit or delete. I had assumed that the button column function that exists in
ASP.NET datagrid would exist in WinForms but it doesn't. Based on that
assumption I created a form with a DataGrid that has a source of a DataTable
(from a DataSet populated by a stored proc).

I'm displaying the data in the DataGrid, but I wanted to have two buttons on
each row, one to edit, the other to delete. I now realized this would take a
good deal of work to implement. I also read this is available in VS 2005
Beta, but this solution needs to be built in VS 2003.

I'm open to other approaches to achieve the same result -- show a list of
rows that allows a user to "select" either a edit or delete function. These
can be buttons, hyperlinks, etc.

Advice would be appreciated, if you post code, please post VB if possible.
Thanks.

Josh.
 
G

Giuseppe Vitalone

Hi, you could use a ListView control (it hasn't a DataSource property, but
you can add items through listView.Add(...) ) and a context menu to edit or
delete the row you click. See documentation for details. Giuseppe
 
J

Jeffrey Tan[MSFT]

Hi Josh,

Thanks for your post.

Yes, I see your concern. Actually, Winform DataGrid is totally a different
DataGrid from Asp.net DataGrid. Winform provided much powful UI, and its
DataGrid databinding is 2 way, that is:
1. After setting the datasource, the underlying datatable data will be
"automatically" parse into DataGrid to display
2. Winform DataGrid has rich UI function, we can edit, add, remove the data
direct in DataGrid, after finish editing, the modified/added/deleted data
will be "automatically" updated to underlying DataSource. This is build-in
feature need no extra coding.

So I think there is no need for us to add an extra button column for
editing. Also, for selection, this is also a build-in function, we can just
click the row header, the entire row will be highlighted for selection
hint.

These are all Winform Rich UI advantage.

Hope this helps.
==============================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

The problem was I wanted to display just a partial list of fields from the
data source then have the user click an Edit button see a form that displayed
all of values. If I reused the same form that was used to insert data, I can
save the time of recreating validation and save functions. Additionally
things such as a state combo box that can be presented on a Form, can't be
presented in the DataGrid, without a great deal of programming.

Also, although I could have lived with it, there was no easy way control
individual column widths.

I'll try the DataGrid again when VS 2005 is released.

Josh.
 
J

Jeffrey Tan[MSFT]

Hi Josh,

Thanks for your feedback.
then have the user click an Edit button see a form that displayed all of
values"
I am not sure I understand you very well. I suspect you only display
partial columns of the underlying DataSource in DataGrid, yes? If it is
true, I think we can implement some similiar function. For example, we can
select certain row in DataGrid without any problem, then we can handle
DataGrid's double click event, and display a edit form, which containing
all the fields(columns) value of that row in underlying datasource. Then
user can edit the values in the edit form. Does this meet your need?
be presented in the DataGrid, without a great deal of programming."
Yes, this is a well known limitation of Winform DataGrid. However, Winform
DataGrid really provided us the way to extend its function with
implementing a customized DataGridColumnStyle. It seems that your current
concern is that this requires a lot of programming. Yes, it is, but
currently, there are a lot of third-party implemented source code for
DataGridComboBoxColumn available, I think you can download and reuse it in
your own application. At least, in one of my application, I reused the
sample DataGridComboBoxColumn from Winform FAQ site.
individual column widths."
I do not know why you get this conclusion. I think Winform associated each
column with a DataGridColumnStyle, and we can use DataGridColumnStyle.Width
property to control individual column width. This is somewhat like Asp.net.
In Asp.net, we also have to use DataGridColumn.ItemStyle.Width property to
control the column width.

At last, yes, because Winform DataGrid control is a highly encapsulated
control, although its function is powful, there are still many functions it
does not implement yet. Our product team has got many feedback about these
issues, and will release DataGridView control in Whidbey to replace
DataGrid control.

If you still have any concern, please feel free to tell me, I will work
with you. Thanks
===========================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Josh,

Does my reply make sense to you? If you still have any concern, please feel
free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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