Ask fill color Text in a Grid View, Grid View data is loaded, the highlighters in grid view under one condition such as larger amounts 1.000 or character as mas ... see attached image file
Loading
Ask fill color Text in a Grid View, Grid View data is loaded, the highlighters in grid view under one condition such as larger amounts 1.000 or character as mas ... see attached image file
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dong Lam TrienPosted Mar 25, 2015, 4:24 AM
[code]
....
}
Joginder BangerPosted Mar 25, 2015, 1:12 AM
Row.Cells[0].Value.ToString();
Dong Lam TrienPosted Mar 25, 2015, 12:57 AM
[code]
private void txtSearchby_TextChanged(object sender, EventArgs e)
{
DataView dv = new DataView(dt); // dataTable
String filter = String.Format(Name LIKE '%{0}%' Or HomePhone LIKE '%{0}%' ,...., txtSearchby.Text);
dv.RowFilter = filter;
dataGridView1.DataSource = dv;
// Fill Highttext Color ?
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string RowType = row.Cells[0].Value.ToString(); // Error here: Object reference not set to an instance of an object.
if (RowType == txtSearchby.Text)
{
row.DefaultCellStyle.BackColor = Color.Yellow;
row.DefaultCellStyle.ForeColor = Color.White;
}
}
}
[/code]
Joginder BangerPosted Mar 24, 2015, 1:00 AM
foreach (DataGridViewRow row in mydataGridView.Rows)
{ string RowType = row.Cells[0].Value.ToString();
if (RowType == "Type A")
{ row.DefaultCellStyle.BackColor = Color.Red; row.DefaultCellStyle.ForeColor = Color.White; }
else if (RowType == "Type B")
{ row.DefaultCellStyle.BackColor = Color.Yellow; row.DefaultCellStyle.ForeColor = Color.Black;
}
}
Dong Lam TrienPosted Mar 23, 2015, 9:31 PM
Khargesh RajputPosted Mar 23, 2015, 1:04 AM
Dong Lam TrienPosted Mar 23, 2015, 12:47 AM
Khargesh RajputPosted Mar 21, 2015, 7:13 AM
Khargesh RajputPosted Mar 19, 2015, 11:50 PM
take label in your column and bind amount on that label and on row databound event
find control of that label and change label color dynamically based on condition
Khargesh RajputPosted Mar 19, 2015, 11:39 PM
your image is not opening in your link
Dong Lam TrienPosted Mar 19, 2015, 10:01 PM
Khargesh RajputPosted Mar 19, 2015, 7:00 AM
as i understadnd you want to change row color
then
on gridview Rowdatabound event
if (e.Row.RowType == DataControlRowType.DataRow) {
if (convert.ToInt32(e.Row.Cells[2].Text)>1)
{
e.Row.Cells[2].ForeColor = System.Drawing.Color.Yellow;
}
}