[爆卦]WPF DataGrid 範例是什麼?優點缺點精華區懶人包

為什麼這篇WPF DataGrid 範例鄉民發文收入到精華區:因為在WPF DataGrid 範例這個討論話題中,有許多相關的文章在討論,這篇最有參考價值!作者GooLoo (平凡)看板C_Sharp標題wpf datagrid問題時間Wed Nov 7...


我可以對datagrid的cell寫入data
我datagrid已經blind 100*100 data

我的Column Header命名是Col1到Col100
問題1:我想修改某cell值,
item[0].Col0=10, item[0].Col1=20,.....
我如何用for幫我對某些局部row, col修改
For (int i=0;i<50;i++)
For(int j=0;j<50;j++)
item[i]. j=10;

因Col1到Col100是一個.......屬性, j是index,是一個int, 無法帶

我看過網頁教學和文件,都是用col1一個一個加

有人知道怎麼做嗎?

問題2:winform時可以Datagrid1. Columns[i]. Rows[j]. isSelected==true)
所以cell依序判isselected
Wpf我試過,找不到isselected

有人知道在wpf怎麼依序判cell是不是isselected呢?




--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.72.44.101
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1541552210.A.46D.html
testPtt: foreach(var cell in DataGrid.SelectedCells) 11/07 11:53
testPtt: 不建議用程式控制ui寫入資料 我實做只會直接寫入不經過ui 11/08 14:13
testPtt: 網路上可能能找到index取得指定cell的方法 11/08 14:15
testPtt: 你在取得cell還要.DataContext再轉型才寫入 11/08 14:18
不懂你的意思耶,有範例嗎? DataContext轉型和直接寫入的範例
網路看到都item整列寫入,而我想修改其中一個cell的值而已
testPtt: 直接修改data內容 或是找到cell.DataContext 11/08 21:14
testPtt: 我從沒做過ui從index去找 最後都要取出item對應的屬性 11/08 21:58
testPtt: 程式碼可能像(cell.item as (type)).屬性=要填的值; 11/08 22:02
testPtt: 屬性大概就你的col1,col2... 11/08 22:07
網上都是教GD1. Col1="10" ,這個我會。但我想做numericupdown去更新我
selected cell,現在已經可以得到selected cell index, 只差cell 不可以用index修
改, c#的datgridview可以culumns[i].Rows[j],WPF不行!
selected cell index是數字, Col1是屬性, 無法帶入
※ 編輯: GooLoo (1.171.26.119), 11/08/2018 23:10:57
testPtt: 如果你是單純數值方陣 那可能不適合DataGrid做 11/08 23:14
testPtt: 你也可以在selected的同時去更新numericupdown的binding 11/08 23:18
對,單純數值矩陣,因為之前datagridview有成功,轉wpf失敗,如果不適合,該用哪一個呢?
※ 編輯: GooLoo (1.171.26.119), 11/08/2018 23:35:44
testPtt: 內建只有DataGrid可以 遇到這種需求我傾向寫usercontrol 11/08 23:44
GooLoo: 瞭解,感謝喔 11/09 12:31

你可能也想看看

搜尋相關網站