特定のセルにアイコンを表示したい。
私はこのコードを使用しています。アイコンを表示したい場所にコメントしました:
string lastScripDate = this.GetLastScripDate(sFolderPath, pb);
string sQuery = "select * from database";
DataTable table = new DataTable();
table = this.Retrieve_Data(sQuery, "database");
pb.Maximum = table.Rows.Count;
pb.Value = 0;
double num = 0.0;
double num2 = 0.0;
double num3 = 0.0;
double num4 = 0.0;
if (table.Rows.Count > 0)
{
for (int i = 0; i < table.Rows.Count; i++)
{
Application.DoEvents();
dgv.Rows.Add();
dgv.Rows[i].Cells["Sname"].Value = table.Rows[i]["Symbol"].ToString();
dgv.Rows[i].Cells["clsprice"].Value = table.Rows[i]["SCRIP"].ToString();
string str3 = table.Rows[i]["TradeType"].ToString();
dgv.Rows[i].Cells["trd"].Value = str3;
string str4 = str3;
if (str4 != null)
{
if (!(str4 == "p"))
{
if (str4 == "q")
{
goto Label_01DD;
}
}
else
{
dgv.Rows[i].Cells["trd"].Style.ForeColor = Color.Green;///////I Want to Display Icon in this Cell(Up.Ico)
}
}
goto Label_020B;
Label_01DD:
dgv.Rows[i].Cells["Trade"].Style.ForeColor = Color.Red;///////////////An Want to Display Icon in this Cell also(Down.Ico
Label_020B:
dgv.Rows[i].Cells["date"].Value = table.Rows[i]["TDate"].ToString();
num = Convert.ToDouble(table.Rows[i]["CPrice"]);
dgv.Rows[i].Cells["tp"].Value = string.Format("{0:0.00}", num);
num2 = Convert.ToDouble(table.Rows[i]["Price"]);
dgv.Rows[i].Cells["tp"].Value = string.Format("{0:0.00}", num2);
num3 = Convert.ToDouble(table.Rows[i]["Loss"]);
dgv.Rows[i].Cells["sl"].Value = string.Format("{0:0.00}", num3);
try
{
num4 = Convert.ToDouble(table.Rows[i]["Ratio"]);
dgv.Rows[i].Cells["Ratio"].Value = string.Format("{0:0.00}", num4);
}
catch
{ }
pb.Value++;
}
if (pb.Value == pb.Maximum)
{
pb.Value = pb.Minimum;
}
return true;
}
return false;