Questions tagged [selecteditem]

selecteditem is a property used to identify the currently selected item in a collection

selecteditem is used to check the state of the associated UI control in several APIs

References

1008 questions
409
votes
5 answers

Difference between SelectedItem, SelectedValue and SelectedValuePath

What is the difference betweeen the following: SelectedItem SelectedValue SelectedValuePath All these dependency properties are defined in Selector class. I often confuse SelectedItem with SelectedValue , and SelectedValue with SelectedValuePath.…
Nawaz
  • 353,942
  • 115
  • 666
  • 851
261
votes
21 answers

Data binding to SelectedItem in a WPF Treeview

How can I retrieve the item that is selected in a WPF-treeview? I want to do this in XAML, because I want to bind it. You might think that it is SelectedItem but apparently that does not exist is readonly and therefore unusable. This is what I want…
Natrium
  • 30,772
  • 17
  • 59
  • 73
77
votes
3 answers

How to cast a System.Windows.Controls.SelectedItemCollection?

I have a method: private void DeletePuzzle(object param) { } param is a System.Windows.Controls.SelectedItemCollection, that I got from a WPF ListView's SelectedItems property. Somehow, I can't seem to cast it from an object to anything useful. I…
Matt Searles
  • 2,656
  • 2
  • 16
  • 18
76
votes
14 answers

Get selected row item in DataGrid WPF

I have a DataGrid, bound to Database table, I need to get the content of selected row in DataGrid, for example, I want to show in MessageBox content of selected row. Example of DataGrid: So, if I select the second row, my MessageBox has to show…
Mike
  • 14,010
  • 29
  • 101
  • 161
60
votes
5 answers

JavaFX TabPane: How to set the selected tab

I have a Java Desktop Application with JavaFX 2 in it and in my FX I've got a TabPane. I want to set the default tab. In other words I want to set a tab as selected. I found that there are multiple ways to find out which tab is selected and I found…
Dorothy
  • 2,842
  • 10
  • 33
  • 46
59
votes
3 answers

WPF TreeView: How to style selected items with rounded corners like in Explorer

The selected item in a WPF TreeView has a dark blue background with "sharp" corners. That looks a bit dated today: I would like to change the background to look like in Explorer of Windows 7 (with/without focus): What I tried so far does not…
Helge Klein
  • 8,829
  • 8
  • 51
  • 71
49
votes
15 answers

Selecting a Textbox Item in a Listbox does not change the selected item of the listbox

I Have a wpf Listbox that display's a list of textboxes. When I click on the Textbox the Listbox selection does not change. I have to click next to the TextBox to select the listbox item. Is there some property I need to set for the Textbox to…
Zack
47
votes
7 answers

Getting selected value of a combobox

public class ComboboxItem { public string Text { get; set; } public string Value { get; set; } public override string ToString() { return Text; } } private void comboBox1_SelectedIndexChanged(object…
maxy
  • 473
  • 1
  • 4
  • 4
43
votes
4 answers

highlighting only the selected item in the listview in Android

I have a list view contactslist. I wrote the code for highlighting the selected item in the ListView. It is working. When I click on one item it is highlighting that item, but the problem is if I click on another item it is highlighting that one…
andro-girl
  • 7,989
  • 22
  • 71
  • 94
40
votes
5 answers

How do you programmatically set focus to the SelectedItem in a WPF ListBox that already has focus?

We want to set the SelectedItem of a ListBox programmatically and want that item to then have focus so the arrow keys work relative to that selected item. Seems simple enough. The problem however is if the ListBox already has keyboard focus when…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
39
votes
1 answer

android listview get selected item

I am new to android, I have a code in which I have placed buttons in list view. My list is as.. Number | Name | ID (visibility = gone) | Level | button1 | button2 Function is different in button 1 and button 2 case. I have applied listeners on…
AZ_
  • 21,688
  • 25
  • 143
  • 191
37
votes
6 answers

WPF binding to Listbox selectedItem

Can anyone help with the following - been playing about with this but can't for the life of me get it to work. I've got a view model which contains the following properties; public ObservableCollection Rules { get; set; } public Rule…
Oli Baylis
  • 373
  • 1
  • 3
  • 4
34
votes
7 answers

QML Listview selected item highlight on click

Hi I want to put this code : highlight: Rectangle { color: "black" radius: 5 opacity: 0.7 focus: true } into mouseArea in onclick handler: MouseArea { id: mouse_area1 z: 1 hoverEnabled: false anchors.fill: parent …
user123_456
  • 5,635
  • 26
  • 84
  • 140
33
votes
4 answers

WPF Tab Control: How do I get the currently selected tab?

In my tab SelectionChanged event (is this the correct event, I can't find a tab changed event?), how do I access the new tab? Also from outside this event in normal code, how do I access the currently selected tab? TabControl.SelectionChanged +=…
Bob
  • 4,236
  • 12
  • 45
  • 65
33
votes
7 answers

What is the simplest way to get the selected text of 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:
DeveloperDan
  • 4,626
  • 9
  • 40
  • 65
1
2 3
67 68