The Data Grid View control replaces and adds functionality to the Data Grid control; however, the Data Grid control is retained for both backward compatibility and future use, if you choose.
See below for details on the differences between the Data Grid and Data Grid View controls.
You can customize sizing behaviors when working with derived Data Grid View cell, row, and column types by overriding the Data Grid View Cell. The protected resizing method overloads are designed to work in pairs to achieve an ideal cell height-to-width ratio, avoiding overly wide or tall cells.
For example, you might programmatically resize all columns immediately after loading data, or you might programmatically resize a specific row after a particular cell value has been modified. Get Preferred Width() methods or by calling protected resizing method overloads in a derived Data Grid View control.
if you dont want to repeat the code then you can cast both the controls, refactor the common actions to a separate method which takes Text Box Base as an argument. Text Box Base as both controls are derived from the Texb Box Base and call the method.
Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
When you want your Windows Forms application to display tabular data, consider using the Data Grid View control before others (for example, Data Grid).
If you are displaying a small grid of read-only values, or if you are enabling a user to edit a table with millions of records, the Data Grid View control will provide you with a readily programmable, memory-efficient solution.
You must then call the Auto Resize Columns method to adjust the column widths to the calculated ideal.
For example, if you call the Auto Resize Rows(Data Grid View Auto Size Rows Mode, Boolean) overload of the Auto Resize Rows method and pass in a value of false for the Boolean parameter, the overload will calculate the ideal heights and widths for cells in the row, but it will adjust the row heights only.