Selecting item in ListBox changes a ComboBox selected item [duplicate] - c#

This question already has answers here:
Comboboxes are linked for some reason
(1 answer)
Bind multiple ComboBox to a single List - Issue: When I select an item, all combo boxes change
(1 answer)
Closed 4 years ago.
In my form I set a listbox and combobox to the same datasource like this
public DetailsForm()
{
InitializeComponent();
this.categories_comboBox.DataSource = TextSelectionSettings.Default.categories;
this.categories_listBox.DataSource = TextSelectionSettings.Default.categories;
}
The items I have listed in the collection show up in the listbox and combobox, but when I click an item in the listbox, it changes the selected item in the combobox, and vice versa. This is not what I expected, because I have no events defined yet for either control.
Is there a way to decouple the two?
EDIT: categories is of type
System.Collections.Specialized.StringCollection
and the TextSelectionSettings are ApplicationSettings

Related

Hide resize & selection column in DataGrid [duplicate]

This question already has answers here:
How Do I Hide wpf datagrid row selector
(4 answers)
Closed 10 months ago.
Is there a way to hide resize & selection column when I add some data in DataGrid's ItemSource?
This is the row selector column and it can be hidden using the HeadersVisibility property.
<DataGrid ... HeadersVisibility="Column">
A value of Column show all column headers but hides the row selectors, see possible values here.

Setting width of ComboBox autocomplete [duplicate]

This question already has answers here:
Combo box drop down width on suggest
(3 answers)
Closed 2 years ago.
In the WinForms combobox, the width of the drop-down can be set programmatically, as in the following example, code and screenshot:
myComboBox.DropDownWidth = 300;
For the combo box, I have enabled the autocomplete:
myComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
myComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
The autocomplete drop-down appears as follows:
How can I set the width of the drop-down containing the suggested items?
I believe that is not possible. You'll probably have to create a custom control to achieve what you need.
Here some information that might be useful for you:
https://social.msdn.microsoft.com/Forums/windows/en-US/f88f37c9-95f9-4f2f-84b5-e262f49a009d/autocomplete-suggest-box-can-this-be-influenced?forum=winformsdesigner

How, when you bind data to a collection, do you set it to a property? [duplicate]

This question already has answers here:
Binding a WPF ComboBox to a custom list
(4 answers)
WPF: How to bind object to ComboBox
(3 answers)
Closed 3 years ago.
Say what I have is an ObservableCollection<People> ListOfPeople such that:
public class People
{
public string Name { get; set; };
}
I have a combobox written equivilent to:
<ComboBox x:Name="combobox_Profiles" Text="Select Person"
ItemsSource="{Binding Path=???}">
How can I set the items within the combobox to be the value of each Name property? I thought I knew how to do this, but I clearly do not.
To select what to show in the case of a single property use the DisplayMemberPath and set it to Name.
You can also set the SelectedValuePath if you want the control to return a specific property of the object rather than the object itself.

CheckedListBox don't check on item selection [duplicate]

This question already has answers here:
CheckedListBox Control - Only checking the checkbox when the actual checkbox is clicked
(6 answers)
Closed 5 years ago.
I have a WinForms CheckedListBox and when I click on an item, it checks it in the list (I have CheckOnClick set to True). I want to change it so that the user must explicitly click the checkbox in order to check that item.
Sorry, misread ur question check the below link instead
CheckedListBox Control - Only checking the checkbox when the actual checkbox is clicked

How to add treeview selected items inside the datagridview columns as a treeview c# [duplicate]

This question already has an answer here:
Host TreeView in Windows Forms DataGridView Cells
(1 answer)
Closed 6 years ago.
I have a form which is having one treeview and datagridview in a form, now i want to insert treeview selected nodes to inside the datagridview with a treeview!
treeview(treeview selected nodes) inside datagridview!
Check out this which has Treeview with Columns
http://www.codeproject.com/Articles/23746/TreeView-with-Columns

Categories