PDA

View Full Version : فرستادن ردیف های انتخاب شده در یک دیتاگریدویو به یک دیتاگرید ویوی دیگه



javad1364
جمعه 17 اسفند 1386, 13:38 عصر
سلام من یک برنامه با c# 2005 نوشتم که می خوام ردیف های انتخاب شده در یک دیتاگریدویو رو به یک دیتاگرید ویوی دیگه منتقل کنم چه کار باید کنم ؟

hassan razavi
جمعه 17 اسفند 1386, 14:23 عصر
با استفاده از خاصیت SelectedRows میتونید اینکار رو به راحتی انجام بدهید
مثال MSDN



private void DataGridView1_UserDeletingRow(object sender,
DataGridViewRowCancelEventArgs e)
{
DataGridViewRow startingBalanceRow = DataGridView1.Rows[0];

// Check if the Starting Balance row is included in the selected rows
if (DataGridView1.SelectedRows.Contains(startingBalan ceRow))
{
// Do not allow the user to delete the Starting Balance row.
if (e.Row.Equals(startingBalanceRow))
{
MessageBox.Show("Cannot delete Starting Balance row!");
}

// Cancel the deletion if the Starting Balance row is included.
e.Cancel = true;
}
}