xaml - Get data from selected row in Gridview in C#, WPF -
I am trying to retrieve data from a gridview that I have created in XML.
& lt; ListView Name = "chartListView" selectionChanged = "chartListView_SelectionChanged" & gt; & Lt; ListView.View & gt; & Lt; GridView & gt; & Lt; GridViewColumn header = "name" DisplayMemberBinding = "{binding name}" width = "250" /> & Lt; GridViewColumn Header = "Type" DisplayMemberBinding = "{Compulsive Type}" width = "60" /> & Lt; GridViewColumn Header = "ID" DisplayMemberBinding = "{Binding ID}" width = "100" /> & Lt; / GridView & gt; & Lt; /ListView.View> & Lt; / ListView & gt;
I have seen some code like this: -
Gridview line line = Gridview 1 Chosen cry; TextBox2.Text = row.Cells [2]. Text;
However my problem is that my gridview has been created in XML, and it has not been named, that is, I can not make any reference to 'Gridview 1' (or do not know) , And can not do it
Can I refer to my Gridview reference either with C # or XAML or can I use the above code?
Second, can I use the array then? Thanks for any help
TextBox2.Text = row.Cells ["ID"].
.
Yes you can name your gridview:
Lt; GridView X: Name = "chartGridView" & gt; ... & lt; / Gridview & gt;
Make sure that the window definition includes the following:
xmlns: x = "http://schemas.microsoft.com/winfx/2006/ Xaml "
This will enable you to refer to it with your C # code.
Comments
Post a Comment