I created a Windows Forms app that generates reports and it works great. It binds a bunch of DataTables to a bunch of DataGridViews, exports the resulting display to a bitmap, and everyone is happy. I would like to create a service that generates these reports automagically instead of having to run each report by hand in my Forms based app. I am running into a problem where I have a DataTable with rows in it, but when I assign it to be the datasource for one of my DataGridViews, the number of rows in the DataGridView remains at zero.
Here is a snippet of relevant code where I am binding this data (yet it is not updating):
DataGridView testGrid = new DataGridView();
testGrid.BackgroundColor = Color.Yellow;
for (int i = ServerTableDay.Count - 1; i >= 0; i--)
{
testGrid.DataSource = ServerTableDay[i];
}
The test grid always has zero rows no matter which table I try to bind by using the .DataSource =
What am I missing, or is this even possible in a Windows Service?
Based on your heading – No you will not be able to use a DataGridView with a Windows Service because this is a User Interface control and the Windows Service would have no UI control. That being said you might look into writing your output to a logfile if you want to keep track of it.
As for your current winforms setup issue try –