110,535
社区成员
发帖
与我相关
我的任务
分享
public static int RowCount = 0;
public static int SetGetRow
{
set
{
if (RowCount != value) { RowCount = value; }
}
get { return RowCount; }
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
int row = dataGridView1.Rows.Count;//得到总行数
int cell = dataGridView1.Rows[1].Cells.Count;//得到总列数
for (int i = 上架.SetGetRow; i < row; i++)//得到总行数并在之内循环
{
for (int j = 0; j < cell; j++)//得到总列数并在之内循环
{
//精确查找定位
if (toolStripTextBox1.Text.Trim() == dataGridView1.Rows[i].Cells[j].Value.ToString().Trim())
{
//对比TexBox中的值是否与dataGridView中的值相同(上面这句)
dataGridView1.CurrentCell = dataGridView1[j, i];//定位到相同的单元格
dataGridView1.Rows[i].Selected = true;//定位到行
上架.SetGetRow = i + 1; return;//返回
}
}
}
}