selecteditem

How to get the latest selected value from a checkbox list?

狂风中的少年 提交于 2019-11-26 20:27:02
问题 I am currently facing a problem. How to get the latest selected value from a asp.net checkbox list? From looping through the Items of a checkbox list, I can get the highest selected index and its value, but it is not expected that the user will select the checkbox sequentially from lower to higher index. So, how to handle that? Is there any event capturing system that will help me to identify the exact list item which generates the event? 回答1: If I understood it right, this is the code I'd

WPF Datagrid set selected row

你。 提交于 2019-11-26 20:21:27
How do I use the Datagrid.SelectedItem to select a row programmatically? Do I first have to create a IEnumerable of DataGridRow objects and pass the matching row to this SelectedItem property or how do I do it? EDIT: I need to match the cell content of the first columns cell with a TextBox.Text first, before selecting the row. please check if code below would work for you; it iterates through cells of the datagris's first column and checks if cell content equals to the textbox.text value and selects the row. for (int i = 0; i < dataGrid.Items.Count; i++) { DataGridRow row = (DataGridRow

Select item programmatically in WPF ListView

限于喜欢 提交于 2019-11-26 16:24:55
问题 I'm unable to figure out how to select an item programmatically in a ListView. I'm attempting to use the listview's ItemContainerGenerator, but it just doesn't seem to work. For example, obj is null after the following operation: //VariableList is derived from BindingList m_VariableList = getVariableList(); lstVariable_Selected.ItemsSource = m_VariableList; var obj = lstVariable_Selected.ItemContainerGenerator.ContainerFromItem(m_VariableList[0]); I've tried (based on suggestions seen here

Getting selected value of a combobox

戏子无情 提交于 2019-11-26 15:52:52
问题 public class ComboboxItem { public string Text { get; set; } public string Value { get; set; } public override string ToString() { return Text; } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = comboBox1.SelectedIndex; int selecteVal = (int)comboBox1.SelectedValue; ComboboxItem selectedCar = (ComboboxItem)comboBox1.SelectedItem; MessageBox.Show(String.Format("Index: [{0}] CarName={1}; Value={2}", selectedIndex, selectedCar.Text, selecteVal)); }

highlighting the selected item in the listview in android

和自甴很熟 提交于 2019-11-26 10:56:07
问题 I am having 1 list view contactslist . I wrote the code for highlighting the selected item in the ListView . It is working. When I click on 1 item it is highlighting that item but the problem is if I click on other item it is highlighting that too. I want to highlight the selected item only. The previous selection will have to gone when I click on another item. arg1.setBackgroundResource(R.drawable.highlighter); This is the code in the click listener using to highlight the selected item. plz

Get selected row item in DataGrid WPF

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 10:23:01
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 something like: 646 Jim Biology . Alex McBride You can use the SelectedItem property to get the currently selected object, which you can then cast into the correct type. For instance, if your DataGrid is bound to a collection of Customer objects you could do this: Customer customer = (Customer)myDataGrid.SelectedItem; Alternatively you can bind

android listview get selected item

♀尐吖头ヾ 提交于 2019-11-26 09:30:03
问题 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 buttons but when I try to get the ID from list it always shows me the last id. How to know which button was clicked, name and id of related field. I have placed buttons and listener on buttons in getView(...) function. 回答1: final ListView lv = (ListView

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

旧城冷巷雨未停 提交于 2019-11-26 09:16:00
问题 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 remove the original dark blue background but paints a rounded border on top of it so that you see the dark blue color at the edges and at the left side - ugly. Interestingly, when my version does not have the focus, it looks pretty OK: I would like to

WPF Datagrid set selected row

孤人 提交于 2019-11-26 09:00:44
问题 How do I use the Datagrid.SelectedItem to select a row programmatically? Do I first have to create a IEnumerable of DataGridRow objects and pass the matching row to this SelectedItem property or how do I do it? EDIT: I need to match the cell content of the first columns cell with a TextBox.Text first, before selecting the row. 回答1: please check if code below would work for you; it iterates through cells of the datagris's first column and checks if cell content equals to the textbox.text value

Difference between SelectedItem, SelectedValue and SelectedValuePath

北城余情 提交于 2019-11-26 03:13:09
问题 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 . I would like to know the difference between them, and also when do we use them, especially SelectedValue and SelectedValuePath . Please explain their use with some simple examples. 回答1: Their names can be a bit confusing :). Here's a summary: The