EDN Admin
Well-known member
I have a DataGrid that uses a DataTable bound to it.
The table is filled from INI files that provide information about other files in a directory which may be moved in and out, so Im pretty much stuck with the INI files, but that all works fine.
I am able to create the DataTable and fill it with no problems, but after filling it, the DataGrid updates the number of rows, but no data shows up in those rows.
I have verified the table is properly filled during debug. I even rebound the grid and table and called refresh on the grid, and still I have a full grid that isnt populated at all.
<pre class="prettyprint public void GetImageList()
{
int i, j; // Loop indices
string File, // Image filename
TempDir = CDirectoryOutline1.Path + @"", // Add
Master = C.GetStringFromRegistry("CSMasterFile").ToUpper(),
Working = C.GetStringFromRegistry("CSWorkingFile").ToUpper();
string[] Files; // Array for pathnames
Cursor.Current = Cursors.WaitCursor; // Might take time
table.Clear(); // Clear data from table
DataRow row = null; // Make an empty row
Files = Directory.GetFiles(CDirectoryOutline1.Path + @"", "*.img");
for (i = 0; i < Files.Length; i++) {
File = Path.GetFileName(Files).ToUpper();
if ((File == Master) || // Exclude Master C&S
(File == Working) || // Working C&S
(File == "BLANK.IMG")) // and blank image files
continue;
row = table.NewRow(); // Make a new row
INIFile ini = new INIFile();
// Set INI file name
ini.IniFile(Path.ChangeExtension(Files, "INI"));
// Populate the row
row[0] = i; // Unique ID
row[1] = File; // Image file name
for (j = 2; j < HeaderCount; j++) { // Read in the INI file
row[j] = ini.IniReadValue(iniSection, Headers[j - 1], "");
}
table.Rows.Add(row); // Add row to table
}
StringGrid1.DataSource = table; // Make sure the table is bound
StringGrid1.Refresh(); // Refresh the data grid
Cursor.Current = Cursors.Default; // restore cursor
// sync the selection to the selection edit box
SelectedEdit.Text = table.Rows[0][1].ToString(); // get the name of the first entry
if (SelectedEdit.Text.Trim() == "") // Enable select if available file
SelectBitBtn.Enabled = false;
else
SelectBitBtn.Enabled = true;
}
[/code]
<br/>
Any ideas why I get a properly dimensioned DataGrid, but theres no information in it?
Andy
View the full article
The table is filled from INI files that provide information about other files in a directory which may be moved in and out, so Im pretty much stuck with the INI files, but that all works fine.
I am able to create the DataTable and fill it with no problems, but after filling it, the DataGrid updates the number of rows, but no data shows up in those rows.
I have verified the table is properly filled during debug. I even rebound the grid and table and called refresh on the grid, and still I have a full grid that isnt populated at all.
<pre class="prettyprint public void GetImageList()
{
int i, j; // Loop indices
string File, // Image filename
TempDir = CDirectoryOutline1.Path + @"", // Add
Master = C.GetStringFromRegistry("CSMasterFile").ToUpper(),
Working = C.GetStringFromRegistry("CSWorkingFile").ToUpper();
string[] Files; // Array for pathnames
Cursor.Current = Cursors.WaitCursor; // Might take time
table.Clear(); // Clear data from table
DataRow row = null; // Make an empty row
Files = Directory.GetFiles(CDirectoryOutline1.Path + @"", "*.img");
for (i = 0; i < Files.Length; i++) {
File = Path.GetFileName(Files).ToUpper();
if ((File == Master) || // Exclude Master C&S
(File == Working) || // Working C&S
(File == "BLANK.IMG")) // and blank image files
continue;
row = table.NewRow(); // Make a new row
INIFile ini = new INIFile();
// Set INI file name
ini.IniFile(Path.ChangeExtension(Files, "INI"));
// Populate the row
row[0] = i; // Unique ID
row[1] = File; // Image file name
for (j = 2; j < HeaderCount; j++) { // Read in the INI file
row[j] = ini.IniReadValue(iniSection, Headers[j - 1], "");
}
table.Rows.Add(row); // Add row to table
}
StringGrid1.DataSource = table; // Make sure the table is bound
StringGrid1.Refresh(); // Refresh the data grid
Cursor.Current = Cursors.Default; // restore cursor
// sync the selection to the selection edit box
SelectedEdit.Text = table.Rows[0][1].ToString(); // get the name of the first entry
if (SelectedEdit.Text.Trim() == "") // Enable select if available file
SelectBitBtn.Enabled = false;
else
SelectBitBtn.Enabled = true;
}
[/code]
<br/>
Any ideas why I get a properly dimensioned DataGrid, but theres no information in it?
Andy
View the full article