This is a migrated thread and some comments may be shown as answers.

Add/Edit/Delete in GridView

5 Answers 204 Views
GridView
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 05 Nov 2012, 10:09 PM
Hi im new to winform for my work is all web based. I wanted to create same features like in the web that has add on top of the header and edit and delete column for each row in my grid, this is for security and safety features. Grid will just be readonly during load and only row thats edited will be editable (save and cancel will show on top  of the header). add new row will add blank row (save cancel will show as well on top of the header) . Delete will just prompt.. Is there any sample that I could check? So far I dont seem to like the inserting and editing of winform for it adds when you loose focus on the row, and for edit if you can edit any cell that you clicked.
Hope someone can give some info..

Thanks in advance,RJ

5 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 07 Nov 2012, 10:15 AM
Hello RJ,

Could you please attach some screens on what you are trying to achieve? and we'll take it from there

Best Regards,
Emanuel Varga

Winforms MVP
0
RJ
Top achievements
Rank 1
answered on 07 Nov 2012, 02:27 PM
Hi Emanuel, Please check this link.. I would like to have same functionality like the web (for security reason). either in-line mode or in-form mode during edit.  There's no problem doing this in web but I don't have any idea on doing this on winform.
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx
0
Emanuel Varga
Top achievements
Rank 1
answered on 07 Nov 2012, 03:20 PM
Hello again,

I have to start saying that this is not really supported on winforms, because this is better suited for a web approach where grids don't offer this level of customization.

But if you insist on this, i have a few remarks / questions
- Are you expecting dynamic types on the grid(s)?
- Or are all the types known?
- You will need this for a lot of grids?

First of all, because you cannot benefit from the internal edit mechanism of the grid you would need some kind of edit control generation per field type (if the answer is yes for the dynamic types, of if you have to threat a lot of different types).
After that it should be pretty much straight forward, you could either use a panel to add all of these fields, if the requirements aren't insisting of doing this in row, or a floating panel maybe? above or below the row.

I can give you some pointers and help you a bit in all of these, but i have to warn you that, to achieve this will involve a lot of work.

Best Regards,
Emanuel Varga
Winforms MVP
0
RJ
Top achievements
Rank 1
answered on 11 Nov 2012, 04:56 PM
Thanks seems like I found some sample on how to have a usecontrol that will show whenever you click edit. I just need to check for the code. Reason I want to have this type of approach is to give user different role.. like some user can only edit but cannot add. Some user can only add or delete etc..  all I need to do is to hide those button for them based on their role.
0
Emanuel Varga
Top achievements
Rank 1
answered on 12 Nov 2012, 07:49 AM
Hello,

Just because of roles, you don't need to do all of this work, you can just as easily create a custom grid where you can set the behavior you require.

For instance, have a CustomGridView which checks automatically the CurrentUser.Roles and based on that it either switches to readonly, or disables the new row or whatever you want.

This is a lot easier (and faster) to implement than implementing the editing logic for all types of data.

Plus, you will be loosing all grid related validation and you will have to handle everything in the controls.

Best Regards,
Emanuel Varga
WinForms MVP
Tags
GridView
Asked by
RJ
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
RJ
Top achievements
Rank 1
Share this question
or