PDA

View Full Version : رفتن به سطر بعدی در DataGidView



3Dmajid
یک شنبه 09 خرداد 1389, 11:59 صبح
چه کدی روی یه Button بنویسم که وقتی روش کلیک بشه به سطر بعدی DataGirdView بره.

Ehsan.Saradar
یک شنبه 09 خرداد 1389, 13:27 عصر
پیشنهاد می کنم از کد زیر استفاده کنید :



int index=0;
if(dataGridView1.SelectedCells.Count!=0) // اگر قبلا سطری انتخاب شده بود
index = dataGridView1.SelectedCells[0].RowIndex; // پیدا کردن شماره سطر قبلی
dataGridView1.Rows[index].Selected = false;
index = (index + 1) % dataGridView1.Rows.Count; // پیدا کردن شماره سطر بعدی
dataGridView1.Rows[index ].Selected = true; // رفتن به سطر بعدی

ostovarit
یک شنبه 09 خرداد 1389, 13:35 عصر
چه کدی روی یه Button بنویسم که وقتی روش کلیک بشه به سطر بعدی DataGirdView بره.

یک سرچ بزنید تو همین فروم کلی مثال در این رابطه هست اضافه کردن حذف حرکت بین سلول ها و ...

ASKaffash
یک شنبه 09 خرداد 1389, 13:39 عصر
سلام


this.dataGridView1.MultiSelect = false;
if (this.dataGridView1.CurrentCell != null || this.dataGridView1.CurrentCell.RowIndex < this.dataGridView1.RowCount - 1)
this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex, this.dataGridView1.CurrentCell.RowIndex + 1].Selected = true;