DataGridView Edit Control Templates type changed programmatically

KonTikiSailor

New member
Joined
Dec 24, 2024
Messages
2
Programming Experience
10+
Hi developers,
in ASP .Net gridview it is possible to alternate editing control in current cell when the row is in editing mode: the editing template is defined in aspx html source, and it is usually different from select template.
Is there a way to get same result for c# client application datagridview? I've taken a look in the web and It looks like it is needed to ovverride some other method, but really I hope in some simpler solution (just as ASP .NET).

Thanks for your attention
 
Have you tried:
 
The WinForms DataGridView is almost infinitely customizable. The WinForms GridView on the other hand is very hard to customize without having to jump through major hoops. The WPF GridView is also nearly infinitely customizable.

In general, though, WinForms is pretty much a dead end. Microsoft originally killed off support for it when .NET Core was started, but was only resurrected because enough of the industry complained that MS told them to write line-of-business apps using WinForms, and then all of sudden saying new code should be written using .NET Core -- but sorry no WinForms support. My understanding is that even though WinForms support is now in .NET, MS is not planning on investing more resources into it other than maintenance for security issues.

 
Last edited:
It is possible to change the type of any cell. More correctly, it's possible to replace any cell with one of any other type. When you create a column, that creates a template for the cells in that column and every cell in that column will use the template by default. You can replace any cell with a different type though, and that cell will then use the standard editing control for its type rather than for the default type of the column. For instance, let's say that you add a text box column to a grid. Each cell in that column will then use a TextBox control for editing. You can put a combo box cell somewhere in the column manually though, then that cell will use a ComboBox control for editing, e.g.
C#:
dataGridView1[textBoxColumnIndex, rowIndex] = new DataGridViewComboBoxCell();
 
Back
Top Bottom