Example #1
0
        private void PopulateListView(string sql)
        {
            try
            {
                dataGridViewFiles.Rows.Clear();
                //"select FileName, FileExtension, FilePath, FileSize, FileTypeId, a.UserComment as FileUserComment,b.UserComment as DiskName from FileIndex a,  PhysicalDrives b where a.DriveId = b.DriveId";
                SQLiteCommand command = new SQLiteCommand(sql, LocalSqllite.m_sqlLiteConnection);
                SQLiteDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    FileData data = new FileData();
                    data.FileName           = reader["FileName"].ToString();
                    data.FileExtension      = reader["FileExtension"].ToString();
                    data.FilePath           = reader["FilePath"].ToString();
                    data.FileSize           = reader["FileSize"].ToString();
                    data.FileTypeId         = reader["FileTypeId"].ToString();
                    data.FileUserComment    = reader["FileUserComment"].ToString();
                    data.DiskName           = reader["DiskName"].ToString();

                    AddFileToDataGridView(dataGridViewFiles, data);
                }

                UpdateRecordLabel();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #2
0
        private void AddFileToDataGridView(DataGridView dgv, FileData fileData)
        {
            int nNewRow = dgv.Rows.Add();
            int nColCount = 0;

            dgv.Rows[nNewRow].Cells[nColCount++].Value = fileData.FileName;
            dgv.Rows[nNewRow].Cells[nColCount++].Value = fileData.FileExtension;
            dgv.Rows[nNewRow].Cells[nColCount++].Value = fileData.FilePath;
            dgv.Rows[nNewRow].Cells[nColCount++].Value = fileData.FileSize;
            dgv.Rows[nNewRow].Cells[nColCount++].Value = fileData.FileTypeId;
            dgv.Rows[nNewRow].Cells[nColCount++].Value = fileData.FileUserComment;
            dgv.Rows[nNewRow].Cells[nColCount++].Value = fileData.DiskName;

            // Assosiate driveData with this row.
            //dgv.Rows[nNewRow].Tag = fileData;
        }