selecteditem

Why in C# , in the control combobox , i can't change the property SelectedItem ?

I have a simple class called Tuple. which looks like this : class tuple { string name; string code } i inserted few of these items into a combobox, now when i want to select through the code some item, i try to write myComboBox.selectedItem = new tuple("Hello" , "5"); and of course it doesn't work at all and the selected ...

getting the selected value on an asp.net mvc selectlist

Hello, I'm failing at getting the selected item on a mvc dropdown list. I can't stand viewdata, and every example uses it. Here is my code, thanks in advance. //controller public ActionResult Register(Models.Person APerson) { } public class Person { public Person() { using (var mod...

WPF: What is the simplest way to get the selected text in a combo box containing only text entries?

My WPF ComboBox contains only text entries. The user will select one. What is the simplest way to get the text of the selected ComboBoxItem? Please answer in both C# and Visual Basic. Here is my ComboBox: <ComboBox Name="cboPickOne"> <ComboBoxItem>This</ComboBoxItem> <ComboBoxItem>should be</ComboBoxItem> <ComboBoxItem>easie...

wpf - ListBox - bind SelectedItem to an xml attribute?

I have a listbox on a usercontrol which is populated by a xml file. <Machines xmlns=""> <Machine Name="Prod1" IP="192.168.1.200" isDefault="true" InstanceName="sql08" /> <Machine Name="Prod2" IP="192.168.1.101" /> <Machine Name="Test1" IP="192.168.1.103" /> <Machine Name="Test2" IP="192.168.1.104" /> </Machines> I would like t...

How can I set a ListView's selected item based on it's ID in a query string on page load?

Question basically crams it all in... I'm loading a page with a querystring (ID), and I need to use that ID to set the selected item of a ListView when the page loads. The ID is a DataKey on the ListView. Please help! I have no code of value to post--none of my attempts at this work. ...

getItemAtPosition() How to get readable data from the selected item in a ListView

I have a listView of contacts that I got from the Android ContactManager sample. This list is showing up fine, but I can't figure out how to get info from the selected item, like "name" and "phone number". I can get the selected position, but the result of the mContactList.getItemAtPosition(position) is a ContentResolver$CursorWrapperI...

Cannot access the selected items collection when the ListView is in virtual mode ?

I have a ListView in Virtual Mode. I wanna to access SelectedItems property. But when I use ListView1.SelectedItems , I receive the following Exception : Cannot access the selected items collection when the ListView is in virtual mode How can I access to ListView1.SelectedItems in VirtualMode. ...

Get selected row item in DataGrid WPF

Hi, I have a DataGrid, binded to Database table, I need to get content of selected row in DataGrid, for example, I want to show in MessageBox content of selected row. Example of DataGrid: ID Name Domain 464 Alex Math 646 Jim Biology So if I select second row, my MessageBox has to show something like: «646 Jim Biology». Thanks. ...

WPF ListView selection cannot be cleared on load?

I looked at several related answers, and determined that I can programmatically clear the selection by setting lstData.SelectedIndex = -1; However, when I do it right after setting the data context on startup, somehow it never works and gets set to select the first element in the list. I also tried adding the setting to the XAML, and -1...

combobox with different datacontext for ItemsSource and SelectedItem

So i have a combobox as the CellEditingTemplate of a datagrid and selected item is bound to the datacontext of that row as expected, but i need the combobox to be populated from a ObservableCollection outside of the context of the datagrid from the ViewModel. How could i acheive this? Thanks ...