TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
prabha haran
NA
81
32.5k
how to change a row color in grid based on condition
Apr 3 2017 1:02 AM
in windows form i have a grid in that i have two column if avilable quantity is less than minimum qty i have make the row as red
my code is
public void SelectStockAvailblity()
{
try
{
DataSet ds = stockDAL.Rawmaterialselect(stockBAL);
if (ds.Tables[0].Rows.Count >= 0)
{
dgvStockAvailabilityList.DataSource = ds.Tables[0];
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
foreach (DataGridViewRow row in dgvStockAvailabilityList.Rows)
{
//if (Convert.ToInt64(ds.Tables[0].Rows[0]["Available Quantity"]) < Convert.ToInt64(ds.Tables[0].Rows[0]["Minimun Quantity"]))
//{
var minquty = ds.Tables[0].Rows[i]["Minimun Quantity"].ToString();
var totalqty = ds.Tables[0].Rows[i]["Available Quantity"].ToString();
if (Convert.ToInt64(row.Cells[2].Value) < Convert.ToInt64(row.Cells[3].Value!=null))
{
this.dgvStockAvailabilityList.DefaultCellStyle.ForeColor = Color.Red;
//this.dgvStockAvailabilityList.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
}
else
{
dgvStockAvailabilityList.CurrentCell.Style.ForeColor = Color.Beige;
}
}
//}
}
//this.dgvStockAvailabilityList.Columns["Miscellaneous Quantity"].Visible=false;
//this.dgvStockAvailabilityList.Columns["EmpId"].Visible = false;
}
else
{
// MessageBox.Show("No records found");
}
}
Reply
Answers (
1
)
Connection between android and PC
how to round off 23.01 as 24 in sql server