DataGridView C#

Change font size and row Height

For specific cell and rows in List HeadlineRow = new List();

1
2
3
4
5
6
7
8
9
10
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.Font = new Font(dataGridView1.Font.FontFamily, 14, FontStyle.Bold);


foreach (var item in HeadlineRow)
{
DataGridViewRow row = dataGridView1.Rows[item];
dataGridView1.Rows[item].Cells[1].Style.ApplyStyle(style);
row.Height = 30;
}

https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control

Change column Width

For specific row in List HeadlineRow = new List();

1
2
DataGridViewColumn column = dataGridView1.Columns[1];
column.Width = 600;

Automatic wrap Line

1
2
dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

https://stackoverflow.com/questions/2154154/datagridview-how-to-set-column-width

Check for empty Cell

Columns = Enum

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 DataTable dt = new DataTable();

DataRow dr = dt.NewRow();

if (!dr.IsNull("ColumnName"))
{
dt.Rows.Add(dr);
dr = dt.NewRow();
CurentColumn = Columns.none;
if (Headline)
{
HeadlineRow.Add(rowNum);
Headline = false;
}
rowNum++;
}

Drag & Drop

https://social.msdn.microsoft.com/Forums/vstudio/en-US/644ebd2b-1760-4c8e-9faf-63f7c0d2cba5/drag-and-drop-not-working-with-windows-81?forum=vbgeneral

Read data from Text File and put it to datagridview

How to read /load text (*.txt) file values in datagridview using C# ..?