question

MRUTYUNJAYAMAHAPATRA-6389 avatar image
0 Votes"
MRUTYUNJAYAMAHAPATRA-6389 asked karenpayneoregon answered

DataGridTextBoxColumn in .Net 5

Hi, We are migrating our prpject to .Net 5
DataGridTextBoxColumn is deprecated in >Net 5 .Can anybody please tell me that what is the corresponding of that .Net 5

dotnet-csharpwindows-10-networkdotnet-runtimewindows-platform-network
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your reply. What are the corresponding method of Edit, SetColumnValueAtRow and GetColumnValueAtRow,



These methods are part of DataGridTextBoxColumn What are the corresponding method to override in DataGridViewTextBoxColumn

0 Votes 0 ·
JerryCai-MSFT avatar image JerryCai-MSFT MRUTYUNJAYAMAHAPATRA-6389 ·

Hi,@MRUTYUNJAYAMAHAPATRA-6389 Are you using a winforms now? What is the Edit method? You can check the source code and overwrite related method:referencesource.microsoft.com

0 Votes 0 ·

yes, I am using Winform, Edit method was method of DataGridTextBoxColumn. it is deprecated for .Net 5. I may need to use DataGridViewTextBoxColumn .Edit method is not in DataGridViewTextBoxColumn .How can I implement this..

0 Votes 0 ·
Show more comments
Viorel-1 avatar image
0 Votes"
Viorel-1 answered MRUTYUNJAYAMAHAPATRA-6389 edited

According to documentation, the new controls seem to be DataGridView and DataGridViewTextBoxColumn.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your reply. What is the corresponding method of Edit,

These methods are part of DataGridTextBoxColumn What are the corresponding method to override in DataGridViewTextBoxColumn


public class DataGridComboBoxColumn : DataGridViewTextBoxColumn
{

              protected override void Edit(System.Windows.Forms.CurrencyManager 
         source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, 
         string instantText, bool cellIsVisible)
     {
         base.Edit(source, rowNum, bounds, readOnly, instantText, 
             cellIsVisible)


Earlier DataGridComboBoxColumn was derived from DataGridTextBoxColumn and Edit method was overrided.

Now if I wlll derive DataGridComboBoxColumn from DataGridViewTextBoxColumn, I would like to know corresponding of Edit method in DataGridViewTextBoxColumn.

I saw msdn documentation that there is no Edit in DataGridViewTextBoxColumn. So how can I implement this ?

do I need to use DataGridView for same.. ?










0 Votes 0 ·
karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered

If open to an alternate way to work with a DataGridView continue.

A consideration would be to use a BindingSource and BindingList (I use a custom BindingList) which means less interaction with the DataGridView except for events.

To work with changes, subscribe to ListChanged event of the BindingList as shown here which is done with Entity Framework (better than working with DataSet/DataTable containers).

If this might be of interest I have a good deal of code samples found here.

One example which auto saves changes
83722-north.png

For working with DataSet/DataTable see the following examples. That example also shows working with a DataGridViewComboBox as well as this code sample.

Last but not least, create your own custom columns e.g.

 public class DataGridViewUpperCaseTextBoxColumn : DataGridViewTextBoxColumn
 {
     public DataGridViewUpperCaseTextBoxColumn() : base()
     {
         CellTemplate = new DataGridViewUpperCaseTextBoxCell();
     }
    
     public sealed override DataGridViewCell CellTemplate
     {
         get => base.CellTemplate;
         set => base.CellTemplate = value;
     }
 }
    
 public class DataGridViewUpperCaseTextBoxCell : DataGridViewTextBoxCell
 {
     public DataGridViewUpperCaseTextBoxCell() : base() { }
     public override Type EditType => typeof(DataGridViewUpperCaseTextBoxEditingControl);
 }
    
 public class DataGridViewUpperCaseTextBoxEditingControl : DataGridViewTextBoxEditingControl
 {
     public DataGridViewUpperCaseTextBoxEditingControl() : base()
     {
         CharacterCasing = CharacterCasing.Upper;
     }
 }




north.png (63.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.