I DataGridView를 채울 수있는 다음 코드가Linq에있는 DataGridView에 다시 KeyValuePair (또는 유사)에
var results = from loc in dtLocations.AsEnumerable()
join con in dtContacts.AsEnumerable() on (int)loc["contactid"] equals (int)con["id"]
select new
{
id = con["id"],
mpoc = loc["mpoc"],
directno = loc["directno"],
extension = loc["extension"],
faxno = loc["faxno"],
billing = con["billing"],
fullname = con["fullname"],
mobno = con["mobno"],
email = con["email"]
};
dgv.AutoGenerateColumns = false;
dgv.DataSource = results.ToList<object>();
하지만 내가 셀을
private void dgvLocations_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridView dgv = sender as DataGridView;
????? vals = ((List<object>)dgv.DataSource)[e.RowIndex];
object id = vals.id; //errors of course
}
I을 클릭하면 다시 읽어 질수 Visual Studio의 감시자 패널에서 목록에있는 요소를 확인할 수 있음을 알 수 있지만 다시 읽으려면 값을 설정해야하는 유형을 파악할 수 없습니다. (
익명 형식입니다. * 정적 유형 (소개되었을 때를 제외하고)으로 표현 될 수 없습니다. 명명 된 (익명이 아닌) 유형이나'동적'또는 (더 칙칙한,'객체'와 명시 적 리플렉션)을 사용하십시오. –