I have a DataGridView bound to a DataTable. The DataTable is populated from a database query. The table contains a column named BestBefore. BestBefore is a date formatted as a string (SQLite doesn't have date types).
I would like to programmatically add a new column to the DataGridView called Status. If BestBefore is less than the current date, Status value should be set to OK, otherwise Status value should be set to NOT OK.
I'm very new to Winforms, so some example code would be greatly appreciated.
UPDATE:
I think DataColumn.Expression is okay for doing simple calculations such multiplying a column's integer value by another value, but what about doing what I need to do? That is, calculate the difference between now and the date (string formatted) in the BestBefore column to determine what value to give the new status column. Example code would be appreciated.
Right-click on the DataGridView in the designer and select Add Column. The Add Column dialog will appear. Select "Unbound Column." Change the Name of the column to "itemTotalDataGridViewTextBoxColumn".
The first column should display the measurement variable(height, weight, plood pressure, etc). To start the examination user click on start examination button. On click of start new examination a new column should be added to grid to enter examination data against measurement variable.
Keep it simple
dataGridView1.Columns.Add("newColumnName", "Column Name in Text");
To add rows
dataGridView1.Rows.Add("Value for column#1"); // [,"column 2",...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With