Reputation: 10638
I have a datagridview in my winforms c# app in .net 3.5 and visual studio 2008.
From code, in the form constructor, and after InitializeComponent() method I set the datagridview's datasource as below:
this.dtItems = new DataTable();
this.dgv.DataSource = this.dtItems;
dtItems.Columns.Add(String.Empty, typeof(byte[])); // This will contain a png image, and I do not want to put a header text so string.empty used but it does not work
dtItems.Columns.Add("Date", typeof(DateTime));
dtItems.Columns.Add("ID", typeof(string));
dtItems.Columns.Add("Name", typeof(string));
dtItems.Columns.Add("Department", typeof(string));
dtItems is a private global variable of DataTable type:
private DataTable dtItems = null;
Problems I have:
Updated:
Second point solved by using below line of code:
dgv.RowHeadersVisible = false;
Upvotes: 0
Views: 77
Reputation: 2499
To remove first column use RowHeadersVisible and set it to false.
To make column without text simply add " "
(with space) and it will work visually but if you want to detect if String.IsNullOrEmpty()
it will say false so you will need to use if String.IsNullOrWhiteSpace()
Upvotes: 1