1
填充我有填充一個DGV,看起來像通過查詢
private void textBox6_Leave(object sender, EventArgs e)
{
DataClasses3DataContext db = new DataClasses3DataContext();
int matchedAdd = (from c in db.GetTable<prop>()
where c.HOUSE_NO.Contains(textBox1.Text) && c.Direction.Contains(textBox2.Text) && c.street.Contains(textBox3.Text) && c.SUFF.Contains(textBox4.Text)
select c.ID).SingleOrDefault();
var before = (from c in db.GetTable<prop>()
where c.ID < matchedAdd
orderby c.PARCEL descending
select c).Take(6);
var after = (from c in db.GetTable<prop>()
where c.ID > matchedAdd
orderby c.PARCEL
select c).Take(6);
var endResult = before.Concat(after);
dgvBRT.DataSource = endResult;
}
我需要能夠通過查詢其填充後,選擇從DGV行和開BRTDetail查詢綁定的DataGridView的選中行。這是我第一次不得不使用未綁定的網格。我通常使用的代碼如下。很明顯,它不起作用,因爲BRTDataSet在那個時候是不相關的。在這種情況下如何選擇一行?
private void dgvBRT_DoubleClick(object sender, EventArgs e)
{
System.Data.DataRowView SelectedRowView;
BRTDataSet.propRow SelectedRow;
SelectedRowView = (System.Data.DataRowView)propBindingSource.Current;
SelectedRow = (BRTDataSet.propRow)SelectedRowView.Row;
frmBRTDetail BRTDetail = new frmBRTDetail(this);
BRTDetail.LoadBRTNumberKey(SelectedRow.PARCEL, null);
BRTDetail.LoadBldgKey(SelectedRow.BLDG_CD, null);
BRTDetail.Show();
}
ItemTemplate代碼適用於webforms是否正確?這是一個winform應用程序。 – korrowan 2013-04-23 20:51:31
我沒有看到它是一個winform。我認爲邏輯背後的代碼仍然有效。你可能需要調整語法。 – briskovich 2013-04-23 22:05:26