Daniel Prado Velasco 29-Dec-10 14:20 29-Dec-10 14:20 Thank you very much for your article I was looking for something like you describe here and finally found your code. It has been of great help for me. I have done a small number of changes to the component and implemented also a solution for the management of INotifyPropertyChanged interface in nested objects. All these changes and improvements are described and available from a project I have created in Google Code, in the following direction: Hope it can help others to take adventage of this component Thanks Daniel. Someone@AnotherWorld 10-Mar-09 8:21 10-Mar-09 8:21 Hi, nice stuff!
But after a couple of time using your solution I realize the ObjectBindingSource ignores the PropertyChanged event of nested objects. I've got a class 'Foo' with two properties named 'Name' and 'Bar'. 'Name' is a string an 'Bar' reference an instance of class 'Bar', which has a 'Name' property of type string too and both classes implements INotifyPropertyChanged.
With your binding source reading and writing with both properties ('Name' and 'BarName') works fine but the PropertyChanged event works only for the 'Name' property, because the binding source listen only for events of 'Foo'. One workaround is to retrigger the PropertyChanged event in the appropriate class (here 'Foo'). What's very unclean! The other approach would be to extend ObjectBindingSource so that all owner of nested property which implements INotifyPropertyChanged get used for receive changes, but how?
Datagridview Examples
Marty Spallone 16-Dec-08 10:39 16-Dec-08 10:39 Hi, this is a great component - exactly what I was looking for - I started to create my own and then I came across your article. I could not load your project with vs.2008 for some reason. Maybe you can post the 2008 version complete? I pulled all the necessary files and created a class library and when I used the object binding source instead of my own class that implemented ITypedList, I found a few problems. For some reason in my dataGridView1DataBindingComplete I got a stack overflow on setting the value of one of the cells which is a checkbox column.
That was strange. The DataBindingComplete would get called recursively in the call to cells'column'.Value = true; // check box. My current solution that worked before your method had a gridview with autogenerate columns and one check box column and autogenerate on the remaining columns. I was hoping to just remove my custom list, ITypedList and replace it with IList and use your binding source but then I got problems in the designer creating the checkbox column header and then the stack overflow above when I set the data source at runtime. I was going to look at your actual demo but can't seem to load it in vs2008.
Any ideas would be helpful. Problem: Create a grid view that has two columns, a check box and a name field, which is a nested object reference - that's it. Not that difficult (for starters). I was a little confused as to whether I needed to create the binding columns in the binding source or do them in the grid - since I need a check box column. Do I need both or can I just use the grid with auto generate columns?
I know this is all confusing - maybe I can create a side project with the problem in it and send you the code example. Thanks Matry. Sorry for the late reply!! It would be great if you could send me a project that demonstrates the problem. I have not updated this code in a long time, but I plan to update this to 2008 as soon as I get the time to do it. The reason it can't load into VS2008 is actually the namespace I selected for my core library (System.Core).
I kind of thought it was a good name, but unfortunately so did Microsoft They now have their own System.Core namespace that collides with the one I did. Lesson learned.
Don't extend the system namespaces Anyhow. Send me an example project and I will see if I can help you out. Regards Bernhard Richter ([email protected]). Izzet Kerem Kusmezer 22-Sep-08 7:49 22-Sep-08 7:49 I liked your code, i converted it to VB.NET and found some performance bottlenecks when testing with 1000000 calls to SetProperty Method.
So decided to improve the performance i made the following changes: a) Added 2 methods called PopulatePropertySetterAndGetters and PopulateFieldSetterAndGetters which forces the il generation for whole properties and fields. B) Added 4 methods called RetrieveGetHandlerForProperty,RetrieveSetHandlerForProperty, RetrieveGetHandlerForField,RetrieveSetHandlerForField, which exposes the methods dynamically. Member 4565380 20-May-08 4:35 20-May-08 4:35 Hi, Thanks for sharing your idea of this wonderful component.
It is really handy. I am facing one problem while trying to display combobox cells in the grid. I followed just the way you did it but getting the following error: 'The following exception occured in the datagridview: System.FormatException: DataGridViewComboboxCell value is not valid. To replace this default dialog please handle the dataerror event.' Grid's datasource A (List ) combobox cell's dataPropertyName A.R (R is of type SmallClass) combobox cell's datasource r ( List ). Eddy Proft 12-Apr-08 17:22 12-Apr-08 17:22 Hello seesharper, Your ObjectBindingSource component is just what I was looking for, and works great in your demo. However, when I delete the MainForm from the ObjectBindingSourceDemo project, and attempt to recreate it from scratch, the BindableProperty Collection Editor is empty for every one of the ObjectBindingSource components that I created, and neither of the DataGridView controls show any nested properties.
I'm guessing that it has something to do with invalid property paths, but for the life of me, I cannot figure out how to make it work. Your help would be greatly appreciated!
Eddy NEVER MIND - I GOT IT NOW! I finally figured out what seesharper meant when he stated: 'You should note that if an invalid property path is entered, there is no error indicating this.' I was stumped because I thought that the 'Members:' list in the BindableProperty Collection Editor window was auto-populated when the window was opened. Now I realize that the property path has to be manually entered for each member. NickB 15-Jan-08 11:35 15-Jan-08 11:35 Hi, I like this a lot - I've been using it for databinding my objects to DataGridView. Now here comes the nasty question that I can find no suitable answer to. And if you're trying to make a decent o-r mapper, I guess you will need one too!
I'm struggling to deal with null's in ComboBoxes in the datagrid. That is to say that in the gridview, I set the column with a combo's datasource to an objectbindingsource that contains a list of possible choices. But the user is also allowed to choose nothing.
If I add a null to this datasource, combobox throws an ArgumentNullException (in AddRangeInternal). The only 'solution' (in quotes 'cos I don't think it really is one) is to create a 'dummy' null object and check for it.This is unpleasant! And it would seem that Microsoft are not that sympathetic.(this issue appears on microsoft connect, marked as 'closed - won't fix' - see ) Any ideas for a 'nice' solution for this? I was wondering the same thing the other day when writing this article, but honestly I don't know. But all I can say is that Microsoft has a history of being very dataset/datatable oriented.
But I would actually be quite surprised if they don't put it in there. I've seen a lot of requests for this on various forums. I'm about to download the beta now so I will let you know as soon as it is investigated //seesharper Last Visit: 31-Dec-99 19:00 Last Update: 26-Dec-17 14:11 1 General News Suggestion Question Bug Answer Joke Praise Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
I have DataGridView with two columns. The first column is TextBoxCol(DataGridViewTextBoxColumn) and the Second one is ComboBoxCol(DataGridViewComboBoxColumn).
How can I change the value of TextBoxCol when ComboBoxCol changes its selected index value? (This should happen when selected index changed in ComboBoxCol. Not after leaving the column, like dataGridViewCellValueChanged) I have read one topic with almost the same problem that I am having but I dont understand the answer(which should be correct base on the check mark). Here's the link.
. Abstract The first two releases of the.NET Framework (.NET 1.0 and.NET 1.1) left a glaring gap in the data-binding picture. Although developers had a flexible, configurable model for linking almost any control to almost any data source, they didn’t have a practical way to display full tables of information. The only tool included for this purpose was the DataGrid control, which worked well for simple demonstrations but was woefully inadequate for real-world code. Most developers found that the DataGrid was awkward to use, inflexible, and almost impossible to customize. Oddly enough, the DataGrid lagged far behind its ASP.NET counterpart, making it more difficult to display rich data-bound tables in a Windows application than in a web page.
Hello Jeff, The approach requires you to bind the column to all possible values you need to display in its cells and then, bind each editor to a subset of these values, so if you need unique list of guests per row and you have 5000 rows, will end up with 5000 lists at some point. If this does not work for you, feel free to check if our hierarchical grid functionality might suit your needs:. Example of hierarchical grid are available in our Demo application Hierarchy. I hope that you find this information useful. All the best, Stefan the Telerik team.
However, as I have a deadline to finish the project soon and with limited budget I would rather use resources within VS 2008. Thank you for your suggestion. I use to be able to do it easily with datagrid in VS 2003 but as I haven't done any programming for a while and now using vs 2008 I thought may be it was something simple to do with a few lines.