bindinglist

How to create a comparable Image

爷,独闯天下 提交于 2019-12-22 17:39:08
问题 I have a DataGridView which has been bound to a generic BindingList . I want to be able to apply sort and search on columns of type DataGridViewImageColumn . The basic idea is to store a name into the image Tag and use is for sorting and searching. How can I do that? It seems several ways to do it: Creating a new class inheriting System.Drawing.Image and making it comparable. Image is an abstract class and if I inherit from it (as well as IComparable interface), I'll encounter with this error

How to reset bindingsource filter to nothing

ぃ、小莉子 提交于 2019-12-20 04:13:16
问题 Using BindingSource on LINQ to SQL, and having implemented a BindingList in my project, I have to use a Textbox to filter rows in a DataGridView , so when I delete the textbox content, Filter should be reset to nothing. My code is as follows: if (textBox1.Text.Length == 0) { productBindingSource.Filter = null; } else { productBindingSource.Filter = "ProductName = '" + textBox1.Text +"'"; //productBindingSource.RemoveFilter(); } productDataGridView.DataSource = productBindingSource; But this

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

送分小仙女□ 提交于 2019-12-19 11:39:05
问题 I am currently getting exceptions when modifying an IBindingList on multiple threads. Does anyone have a threadsafe version before I write my own? 回答1: 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. 回答2: Only just found this post... do you mean like this? 来源: https://stackoverflow.com

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

可紊 提交于 2019-12-19 11:39:00
问题 I am currently getting exceptions when modifying an IBindingList on multiple threads. Does anyone have a threadsafe version before I write my own? 回答1: 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. 回答2: Only just found this post... do you mean like this? 来源: https://stackoverflow.com

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

吃可爱长大的小学妹 提交于 2019-12-18 09:17:32
问题 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

Get the Enum<T> value Description

拟墨画扇 提交于 2019-12-18 05:03:46
问题 I have my enumHelper class that contains these: public static IList<T> GetValues() { IList<T> list = new List<T>(); foreach (object value in Enum.GetValues(typeof(T))) { list.Add((T)value); } return list; } and public static string Description(Enum value) { Attribute DescAttribute = LMIGHelper.GetAttribute(value, typeof(DescriptionAttribute)); if (DescAttribute == null) return value.ToString(); else return ((DescriptionAttribute)DescAttribute).Description; } my enum is something like: public

Get the Enum<T> value Description

微笑、不失礼 提交于 2019-12-18 05:03:09
问题 I have my enumHelper class that contains these: public static IList<T> GetValues() { IList<T> list = new List<T>(); foreach (object value in Enum.GetValues(typeof(T))) { list.Add((T)value); } return list; } and public static string Description(Enum value) { Attribute DescAttribute = LMIGHelper.GetAttribute(value, typeof(DescriptionAttribute)); if (DescAttribute == null) return value.ToString(); else return ((DescriptionAttribute)DescAttribute).Description; } my enum is something like: public

Create a custom collection like BindingList that works with ListBox to create a ListChanging event

半城伤御伤魂 提交于 2019-12-14 04:00:00
问题 I have a situation where I need to know when an item is going to be added/removed/modified in the collection. I tried by inheriting BindingList in a class that will trigger these events, however the "adding" event doesn't work. The only way I found it working is by overriding EndNew() method, however I don't find a way to get which object is going to be added in this method (if someone has a solution for this, it's ok too!) . So built a totally new class which inherits from same interfaces

Databinding bindinglist to combobox and removing items

六眼飞鱼酱① 提交于 2019-12-13 16:06:22
问题 I am trying to use windows forms databinding to hook up a combobox to a ViewModel class. var items = new BindingList<Person>(); comboBox.DataSource = items; comboBox.DisplayMember = "Name"; All works ok except when I remove items from the list. For example if I remove the currently selected item (selected in the combobox) the selectedIndexChanged and SelectedValueChanged events of the combobox don't fire. 回答1: Found an answer. I had to use a BindingSource as middleman var bindingsSource = new

Binding Listbox to bindinglist, filter on item property

我的未来我决定 提交于 2019-12-13 04:27:41
问题 I'm working on a Winforms application and I have a bindinglist of objects that I want to bind to a listbox. I got this to work, but what I want to do next, is only display items where a particular property is true. So I have a class with a bindinglist class DataBuilder { public BindingList<TableSet> allTableSets = new BindingList<TableSet>(); } And a class TableSet with some properties class TableSet { public string TableSetName {get; set;} public bool IsPopulated {get; set;} } And now on my