2
if文の行番号はどのように取得できますか?戻り行番号cellは文字列に似ています
private void load_session_value()
{
string trans_id = Session["transaction_id_report"].ToString();
string trans_number = Session["transaction_no_report"].ToString();
//string grid_value_id = GridView1
//string grid_value_num
if (trans_id != null && trans_number != null)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.Cells[1].Text.ToString() == trans_id && row.Cells[2].Text.ToString() == trans_number)
{
row.BackColor = ColorTranslator.FromHtml("#A1DCF2");
//GridView1.SelectedIndex = rowIndex;
GridView1.SelectedIndex = ???
GridView1_SelectedIndexChanged(new object(), new EventArgs());
}
}
}
}
私は私がGridView1.SelectedIndex
現在row.color
は、右の行になっているため、行番号が必要です。しかし可能であれば、にはrow.color
が含まれていますか?
int型currentRowの= dataGridView1.CurrentCell.RowIndex。 – jdweng
は、最も内側のif文の行番号を返しますか? –
選択されている現在のセルを返します。 – jdweng