I have data gridview and in one colum contain numeric values and i am trying to apply filters like show greater and etc but I am not able to come with solution.
screen:
code:
calling the class method and assigning the value to datagridview
dataGridViewKeywords = filter.Filter(dataGridViewKeywords, mainValue, true);
Class File:
class FilterDataGridView
{
private DataGridView modifiedDGV = new DataGridView();
private string keyword;
private int competionScore;
DataTable dt = new DataTable();
public DataGridView Filter (DataGridView dgv, int value, bool isabove)
{
modifiedDGV.Columns.Add("keyword", "Keyword") ;
modifiedDGV.Columns.Add("competition", "Avg. Competition Score");
modifiedDGV.Columns.Add("moreinfo", "More Info");
if (isabove)
{
for (int row = 0; row < dgv.Rows.Count; row++)
{
competionScore = Convert.ToInt32(dgv.Rows[row].Cells[1].Value);
keyword = dgv.Rows[row].Cells[0].Value.ToString();
if (competionScore > value)
modifiedDGV.Rows.Add(keyword, competionScore, "View");
}
}
return modifiedDGV;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…