I'm trying to set the datasource of a DataGridView called FileGridView
to a List<object>
called filesAndDirectories
, which contains a list of DirectoryProperties
objects and FileProperties
objects, the variables in which are shown below:
DirectoryProperties
private string _directoryname;
private string _directorytype;
private string _directorysize;
private string _dateCreated;
private string _dateModified;
FileProperties
private string _filename;
private string _filetype;
private string _filesize;
private string _dateCreated;
private string _dateModified;
Binding list to datasource
FileGridView.DataSource = files;
When this list is passed to be the datasource of FileGridView
however, none of the data shows up. Oddly enough, however, the correct number of rows and columns to display the data ARE being shown.
Any ideas as to what I'm doing wrong? The list is obviously having some impact, I'm just not sure why the grid isn't updating.
FileGridView Properties
//
// FileGridView
//
this.FileGridView.AllowUserToAddRows = false;
this.FileGridView.AllowUserToDeleteRows = false;
this.FileGridView.AllowUserToResizeRows = false;
this.FileGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.FileGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColName,
this.ColType,
this.ColSize,
this.ColDateCreated,
this.ColDateModified});
this.FileGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.FileGridView.Location = new System.Drawing.Point(13, 38);
this.FileGridView.MultiSelect = false;
this.FileGridView.Name = "FileGridView";
this.FileGridView.RowHeadersVisible = false;
this.FileGridView.ShowEditingIcon = false;
this.FileGridView.Size = new System.Drawing.Size(503, 376);
this.FileGridView.TabIndex = 4;
this.FileGridView.CellContentDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.FileGridView_CellContentDoubleClick);
Link to project
https://dl.dropboxusercontent.com/u/14954037/SharpManager.rar
FileGridView.DataBind();
– VishalFileGridView.DataSource = files;
and run your program. Check if your files variable has some data in it? – Vishal