我想在文本框中選擇datagrid的值。 我試過下面的代碼如何在文本框中獲取datagrid選定的行值
private void datagrid1_SelectionChange(object Sender, RoutedEventArg e)
{
var selectedrow= datagried1.selectedItem as datarowview;
var id= selectedrow["Tagid"]; //Here get error that object refrence is not set is an instance of an object
string s= conver.tostring(id);
txttextbox1.text= s;
}
它工作正常。
但是當我刷新(重裝)datagrid1
然後selectionChange給我error..that object refrence is not instance of an object.
HTTP:/ /stackoverflow.com/questions/3913580/get-selected-row-item-in-datagrid-wpf – Rohit 2015-03-19 08:03:00
我已經看過這個解決方案,但沒有用爲了我。因爲我不想使用viewmodel – Dipika 2015-03-19 08:30:12
爲什麼再問一次? – Muds 2015-03-19 09:11:44