Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binding textbox, grid column etc to derived property
Message
 
To
08/05/2007 06:35:09
Walter Nicholls
Cornerstone Software Ltd
Auckland, New Zealand
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01223307
Message ID:
01224413
Views:
21
Walter,

>This seems like it ought to work but doesn't. MM.NET 2.4, strongly typed entitiy everywhere. Any ideas?
>
>public class OrderLineEntity: ABusinessEntity
>{
>  public double? Price{ get {...} set {...} }
>  public double? Quantity { get {...} set {..} }
>
>  public double? Total { get { return Price*Quantity;} }
>}
>
>// .. then on form...
>           this.mmTextBox4.BindingSource = "OrderLine";
>            this.mmTextBox4.BindingSourceMember = "Total";
>
>

You can actually use standard VS 2005 data binding to do this (we are preparing documentation that discusses this). Here are the basics.

  1. In Visual Studio, select Data | Add New Data Source from the menu

  2. In the first step of the wizard, select Object

  3. In the second step of the wizard choose the entity object you want to bind to (even if it's an entity list, choose a single entity object)

  4. Click Finish to add the entity object as a data source

  5. To specify the default user interface controls you want added to your form, select Tools | Options from the VS menu, then under Windows Forms Designer | Data UI Customization, select each Data Type on the right side of the dialog and the corresponding UI control you want added to your form. Click the Set Default button to make this the default UI control for a given data type. Click OK to close the dialog when you're done.

  6. If it's not already visible, view the Data Sources window (Shift+Alt+D)

  7. If you want to bind to a DataGridView, in the Data Sources window select the combo box that displays your entity name and pick mmDataGridView (or some other UI control) from the list. If you want to bind to individual controls, in the combo box that displays your entity name, pick Details.

  8. Drag and drop the entity from the DataSources window onto the form. This adds the UI controls as well as a Binding Source object and BindingNavigator in the component tray. If you don't want to use the navigation controls that were added to the form, then delete the BindingNavigator object

  9. Now you just need to set the DataSource property of the BindingSource object. For example:
    this.customerEntityBindingSource.DataSource = this.oCustomer.GetAllEntities();


Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform