1

I've build a base user control, BaseViewControl, it has a dataGridView and a bindingSource on it. Both have protected access modifiers. The dataViewGrids dataSource points to the base forms bindingSource.

Then I created an InheritedUserControl, ApplicationUserView, when prompted I pointed it to my UI assembly. It inherited some other arb UserControl in the same assembly so I manually changed it to inherit my BaseViewControl.

On the ApplicationUserView's bindingSource, I set the dataSource property to my ApplicationUser domain object. The dataGridView then proceeded to populate its columns with the properties in my ApplicationUser domain class in the DesignView, as expected.

Now, in an async callback from my controller object, where the view receives an IList<ApplicationUser>, i set my bindingSource.DataSource = applicationUserList.

I've confirmed that the callback gets called and that the applicationUserList has items in it, but at run time, the grid doesn't show any rows. I suspect it has something to do with the visual inheritance aspect of it all.

I've seen VS create copies of items from inherited forms onto the inheriting form as soon as you try and modify a property of an inherited item before, which has a similar effect, but this is not the case.

Any ideas what I'm doing wrong?

Thanks, HS

HarveySaayman
  • 351
  • 3
  • 12
  • I'll only post a comment as my situation was different, however the control in question was the same. I had trouble with the DataGridView too: http://adamhouldsworth.blogspot.com/2010/02/winforms-visual-inheritance-limitations.html – Adam Houldsworth Aug 26 '11 at 19:43
  • I would check out the designer generated files for the inherited and base controls. – Jeff Aug 26 '11 at 19:50
  • The designer files seems to be correct, the base control declares the DataGridView and the BindingSource, the inheriting control modifies their properties... – HarveySaayman Aug 26 '11 at 19:53
  • I don't think it should be needed but have you tried calling bindingSource.ResetBindings()? – Igby Largeman Aug 26 '11 at 21:00
  • I actually swapped out the DataGridView with a DevExpress grid and boom! Things started working... As far as I've read most of the .net 1 & 2 controls have problems and limitations when it comes to visual inheritance... – HarveySaayman Aug 26 '11 at 22:45
  • Well, DataGridView definitely doesn't support visual inheritance (that's a documented fact), but I didn't think that would cause the particular problem you had. It just means that you can't modify it in the designer from the inherited form/user control. And i'm sure I've done what you're doing and it worked fine. Oh well... – Igby Largeman Aug 27 '11 at 21:53

0 Answers0