가 현재 내 저장소 내 DB에서 데이터를 나열하는 IQueryable
객체를 반환하는 된 IQueryable 개체이며, 내가 그리드에 사용되는 BindingSource
이 바인딩 :액세스 컨텐츠 소스가
public void BindTo(IQueryable elements)
{
BindingSource source = new BindingSource();
source.CurrentChanged += new EventHandler(source_CurrentChanged);
source.DataSource = elements;
elementNavigator.BindingSource = source;
elementGridView.DataSource = source;
}
이를 훌륭하게 작동합니다. 그러나 사용자가 그리드의 행을 클릭 할 때 몇 가지 작업을 수행하려고합니다. 사용자가 선택하는 요소를 식별하는 데 어려움을 겪고 있습니다. 내보기에서
:
private void source_CurrentChanged(object sender, EventArgs e)
{
_presenter.ElementChanged(sender, e);
}
내 발표자에 : 나는 다음이
public void ElementChanged(object sender, EventArgs e)
{
BindingSource source = (BindingSource)sender;
// Here I need to get the ID of the selected element in the source.Current property.
// HOW?
}
이 확인을 작동하는 것 같다 - 그 source.Current
을 디버깅 할 때 내가 볼 수있는 데이터를 포함
? source.Current
{ BodyId = 1, IsInUse = true, IsValid = true, CreateDate = {04/07/2006 09:31:59}, LastUpdateDate = {04/07/2006 09:31:59}, StatusDescShort = "Exist" ... }
BodyId: 1
CreateDate: {04/07/2006 09:31:59}
IsInUse: true
IsValid: true
LastUpdateDate: {04/07/2006 09:31:59}
StatusDescShort: "Exist"
그러나 나는 손실로 인해값에 액세스 할 수 있습니다.. 나는 내가 처음부터 아주 명백한 것을 놓치고 있다는 느낌이 들었다.
흠 읽기 몇 가지 내가 '근본적으로 잘못하고 shouldn라고 생각하기 시작 했어 IQueryable을 전혀 사용하지 않고 목록에 바인딩해야합니다. 이견있는 사람? – Martin