bindinglist

BindingList with my class populating a ComboBox using a property of it?

天涯浪子 提交于 2019-12-06 06:03:52
I have a BindingList with my class where I would like to populate a ComboBox using a property of it so when my list changes the ComboBox would change as well. public class UserAccess { public override string ToString() { return Access; } public int AccessId { get; set; } public string Access { get; set; } public List<string> Command = new List<string>(); public bool HasCommand(string cmd) { return this.Command.Any(x => x == cmd); } } public BindingList<UserAccess> accessList = new BindingList<UserAccess>(); On my form load I assign it to the ComboBox: myComboBox.DataSource = accessList; I want

Why aren't classes like BindingList or ObservableCollection thread-safe?

天大地大妈咪最大 提交于 2019-12-03 05:08:45
问题 Time and time again I find myself having to write thread-safe versions of BindingList and ObservableCollection because, when bound to UI, these controls cannot be changed from multiple threads. What I'm trying to understand is why this is the case - is it a design fault or is this behavior intentional? 回答1: The problem is designing a thread safe collection is not simple. Sure it's simple enough to design a collection which can be modified/read from multiple threads without corrupting state.

Why aren't classes like BindingList or ObservableCollection thread-safe?

风流意气都作罢 提交于 2019-12-02 17:34:09
Time and time again I find myself having to write thread-safe versions of BindingList and ObservableCollection because, when bound to UI, these controls cannot be changed from multiple threads. What I'm trying to understand is why this is the case - is it a design fault or is this behavior intentional? JaredPar The problem is designing a thread safe collection is not simple. Sure it's simple enough to design a collection which can be modified/read from multiple threads without corrupting state. But it's much more difficult to design a collection that is usable given that it's updated from

Using SortableBindingList<T> - DataGridView doesn't automatically sort on changes

南笙酒味 提交于 2019-12-02 00:11:10
I'm building a Windows Forms Application that displays a custom class Record objects and sorts them by how long they've been in my SortableBindingList<Record> record_list . When I start my program, I have some "dummy" records loaded into this list already for the sake of testing. The SortableBindingList<T> has been taken from here . public partial class Form1 : Form { public SortableBindingList<Record> record_list = new SortableBindingList<Record> { }; public static DataGridViewCellStyle style = new DataGridViewCellStyle(); public Form1() { InitializeComponent(); dataGridView.DataSource =

Has anyone written a thread-safe BindingList<T>?

99封情书 提交于 2019-12-01 14:09:39
I am currently getting exceptions when modifying an IBindingList on multiple threads. Does anyone have a threadsafe version before I write my own? I think you'll find this an incredibly difficult task. The easier path would be to prevent multiple-thread access with a lock : void AddItemToList(object o) { lock(myBindingList) { myBindingList.Add(o); } } Look at the lock statement docs for more info. Only just found this post... do you mean like this ? 来源: https://stackoverflow.com/questions/148587/has-anyone-written-a-thread-safe-bindinglistt

Convert IList<T> to BindingList<T>

依然范特西╮ 提交于 2019-11-30 17:16:31
How can I cast an IList<Customer> list to BindingList<Customer> ? LukeHennerley var yourList = new List<Customer>(); var listBinding = new BindingList<Customer>(yourList); BindingList Constructors You don't need to do a cast, just provide the BindingList<T> class constructor with IList<T> , which you have. Unfortunately you can not cast an IList to something its not. However you can create a new BindingList from it fairly easy by just passing your IList into its constructor. BindingList<Customer> bindingList = new BindingList<Customer>(yourIList); BindingList constructor takes IList parameter,

Get Deleted Item in ItemChanging event of BindingList

≡放荡痞女 提交于 2019-11-30 08:16:28
I am using Binding List in my application along with ItemChanged event. Is there any way I could know the previous values of properties in ItemChanged event. Currently I am adding a separate property named 'OldValue' to achieve this. Is there any way to know about the deleted item in item changed event. I am not able to find any way to know which item has been deleted from the list. If I understand correctly, you want to get info about item which was deleted from binding list. I think the easiest way to do this will be creating your own binding list which derives from binding list. Inside you

Why NOT BindingList in WPF

微笑、不失礼 提交于 2019-11-30 06:46:53
I have asked this question on MSDN forums as well ... http://social.msdn.microsoft.com/Forums/en/wpf/thread/4493988a-9bd8-48fe-aff0-348502136a80 I need to know that why Microsoft suggests that BindingList is not properly supported in WPF... What is it that doesnt work with BindingList in WPF? I find it pretty useful as it is. So far I personally have not found BindingList any slower or a having more load on memory. Plus WPF ItemsControls , ItemsTemplates , Styles , Hierarchies work great with BindingList s too. They are equally observable. Being a hardcore WPF developer myself and an

ObservableCollection(Of T) vs BindingList(Of T)?

风流意气都作罢 提交于 2019-11-30 06:44:17
问题 I've developped some data based Winforms Application this last two years and all works fine. This application are built on layers (DataAccess, Business Logic and UI). For the Businness Logic, all my objects inherit from a base class called BaseEntity with the following definition (there are some custom objects and interfaces, combined with framework elements) : Public MustInherit Class BaseEntity Inherits SerializableObject Implements IEntity Implements IComparer, _ IEditableObject, _

Convert IList<T> to BindingList<T>

只谈情不闲聊 提交于 2019-11-30 00:54:28
问题 How can I cast an IList<Customer> list to BindingList<Customer> ? 回答1: var yourList = new List<Customer>(); var listBinding = new BindingList<Customer>(yourList); BindingList Constructors You don't need to do a cast, just provide the BindingList<T> class constructor with IList<T> , which you have. 回答2: Unfortunately you can not cast an IList to something its not. However you can create a new BindingList from it fairly easy by just passing your IList into its constructor. BindingList<Customer>