Omer Butt
Active member
- Joined
- Sep 6, 2021
- Messages
- 29
- Programming Experience
- Beginner
What I tried is: (But need to know what to put in
Please tell in the above mentioned code what to Mention in
if condition and what to put in foreach condition)ViewMedicine_DataGrid is a name of DataGridViewPharmacist_Medicine is a name of a Table in Sql ServerE_Date is a column name of Expiry Date
Code I tried missing if and foreach condition:
private void ViewMedicine_DataGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
string MarkExpire = "select * from Pharmacist_Medicine where E_Date >= getdate()";
SqlDataAdapter ExpCMD = new SqlDataAdapter(MarkExpire, Conn.Connect);
DataTable MrkExp = new DataTable();
ExpCMD.Fill(MrkExp);
if ( )
{
foreach ( )
{
row.DefaultCellStyle.BackColor = Color.Yellow;
row.DefaultCellStyle.BackColor = Color.Red;
}
}
}
Please tell in the above mentioned code what to Mention in
if and foreach conditions to make that code work perfectly to change the color of the row in datagridview based on query.