locked
Inter-Component Databinding? RRS feed

  • Question

  • Hi there,

       I'm fairly new to the .NET platform, so please bear with me if this is a very rookie question.  I'm working on a program where I want two link two visual components to each other; namely, one component shows a list of custom objects on-screen (and allows selection of one), and another component provides further details on the selected object.  What I'd like to do is bind (in whatever sense is appropriate) a "SelectedObject" sort of property on the listing control with the "TargetObject" sort of property on the detailed viewing control.  I thought I could do this with simple databinding, and it will compile and run if the databinding is invoked with a non-null value in the "SelectedObject" property.  However, if I assign null to that property, my application mystically exits with a System.FormatException.  It could be that I'm just not implementing the databinding correctly, but it sounds like databinding is meant to create a link between a backend data source and a visual component, so I don't know if I'm even using the right technique.  Is it appropriate here, where the listing component essentially acts as a backend data source?  Any tips that anybody can offer as to how I should go about this sort of thing, or why I'm getting a FormatException, would be most appreciated - thanks!

    - DJ
    Thursday, April 19, 2007 3:31 AM

Answers

  • You can use a ComboBox to show the list of custom objects, and a DataGridView to show the details, handle ComboBox's SelectedIndexChanged event, change the DataSource of the DataGridView in  the event handler function.
    Wednesday, April 25, 2007 11:18 AM

All replies

  • A bit of an update / further idea on this: it seems like another plausible way of solving this problem is to have my listing control fire an event when the selection is changed, and to have the containing class handle said event by setting the selection on the other visual component.  Is this a more commonly accepted / recommended way to solve the problem?  Thanks in advance.

    - DJ
    Thursday, April 19, 2007 2:13 PM
  • You can use a ComboBox to show the list of custom objects, and a DataGridView to show the details, handle ComboBox's SelectedIndexChanged event, change the DataSource of the DataGridView in  the event handler function.
    Wednesday, April 25, 2007 11:18 AM