selectedvalue

Can't clear ListBox selection using SelectedItem = null - MVVM

谁说胖子不能爱 提交于 2019-11-29 03:43:43
问题 I have the following data template (and a corresponding view model, not shown): <DataTemplate DataType="{x:Type logic:SnapshotListViewModel}"> <ListBox ItemsSource="{Binding Snapshots}" /> </DataTemplate> ItemsSource is bound to a list of Snapshots, found inside the viewmodel. My goal is to clear the SelectedItem, so the listbox goes back to its initial, unselected state. The view model implements IPropertyNotified. I added a binding in the XAML like so: <ListBox SelectedItem={Binding

Get DataGridViewComboboxColumn SelectedValue (VB.Net)

↘锁芯ラ 提交于 2019-11-28 11:54:54
问题 I need to get the selected value of a ComboBox in a DataGridView. I have it partially working, but I get a Null Reference Exception if I change a another ComboBox in the grid. Here's my code: Private Sub dgvSampleList_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles dgvSampleList.EditingControlShowing Dim comboBox As ComboBox = CType(e.Control, ComboBox) If (comboBox IsNot Nothing) Then 'Remove an existing event-handler RemoveHandler

Problems with AJAX CascadingDropDown and DropDownList SelectedValue in EditItemTemplate

*爱你&永不变心* 提交于 2019-11-28 09:33:32
问题 I am having problem in EditItemTemplate of FormView. When I use such code in InsertItemTemplate everything works: <asp:DropDownList ID="Lic_PosiadaczLicencjiIDDropDownList" runat="server" SelectedValue='<%# Bind("Lic_PosiadaczLicencjiID") %>' /> <asp:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="Lic_PosiadaczLicencjiIDDropDownList" Category="Knt_Kod" ServicePath="~/ManagerLicencjiService.asmx" ServiceMethod="GetKontrahenci"> </asp:CascadingDropDown> But when I use

ASP:DropDownList in ItemTemplate: Why is SelectedValue attribute allowed?

核能气质少年 提交于 2019-11-28 07:13:04
问题 This piece of code <asp:DropDownList runat="server" ID="testdropdown" SelectedValue="2"> <asp:ListItem Text="1" Value="1"></asp:ListItem> <asp:ListItem Text="2" Value="2"></asp:ListItem> <asp:ListItem Text="3" Value="3"></asp:ListItem> </asp:DropDownList> yields this error: The 'SelectedValue' property cannot be set declaratively. Yet, this is a legal and commonly used edit template for databound GridViews. The SelectedValue attribute certainly appears to be declaratively set here.

Getting selected value of a combobox

你离开我真会死。 提交于 2019-11-27 12:37:37
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)); } I'm adding them like: ComboboxItem item = new ComboboxItem(); item.Text = cd.Name; item.Value = cd.ID;

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)); }

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