Hi, We are migrating our project to .Net 5
DataGridTableStyle, DataGridColumnStyle is deprecated in >Net 5 .Can anybody please tell me that what is the corresponding of that .Net 5
Hi, We are migrating our project to .Net 5
DataGridTableStyle, DataGridColumnStyle is deprecated in >Net 5 .Can anybody please tell me that what is the corresponding of that .Net 5
Hi MRUTYUNJAYAMAHAPATRA-6389,
As document said that starting with .NET Core 3.1, various Windows Forms controls are no longer available, such as DataGrid.
And associated APIs (DataGridTableStyle, DataGridColumnStyle, DataGridLineStyle...)that are removed.
The recommended replacement is DataGridView, you can see all the properties and methods it currently supports in this document.
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hello,
Best to use a DataGridView, format cells using CellFormating event. Although a DataGrid has been around for a long time, since the DataGridView arrived this is the recommended way to work with data. Upside, you have more control over styling, downside, styling requires more effort on the part of a developer.
The following Microsoft Word document should be more than enough to help with formatting and more.
Resources for formatting
Thanks for your reply . May I know how can I implement Table Style..
It is implemented as below. which is not working in .Net 5. How can I migrate code below to .Net 5
private void setupTableStyle()
{
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "DataFilesTable";
tableStyle.ColumnHeadersVisible = true;
tableStyle.RowHeadersVisible = false;
DataGridColumnStyle colStyle = new DataGridComboBoxColumn( 100, null );
colStyle.MappingName = "Disk Drive";
colStyle.HeaderText = "Disk Drive";
colStyle.Width = 83;
((DataGridComboBoxColumn)colStyle).ComboBox.DataSource = diskDrivesView;
((DataGridComboBoxColumn)colStyle).ComboBox.DisplayMember = identifier.ColumnName;
((DataGridComboBoxColumn)colStyle).ComboBox.ValueMember = driveAlias.ColumnName;
tableStyle.GridColumnStyles.Add( colStyle );
dataFilesGrid.TableStyles.Add( tableStyle );
Hi @MRUTYUNJAYAMAHAPATRA-6389,
First, you need to know that neither DataGridTableStyle or DataGridColumnStyle is applicable to .Net 5.
As we said before, the recommended replacement is DataGridView in .Net 5.
And the DataGridView control provides a customizable table for displaying data.
The DataGridView class allows customization of cells, rows, columns, and borders through the use of properties such as DefaultCellStyle, ColumnHeadersDefaultCellStyle, CellBorderStyle, and GridColor.
For more information, see Basic Formatting and Styling in the Windows Forms DataGridView Control.
Best Regards,
Daniel Zhang
13 people are following this question.