Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Probably taking the wrong approach
Message
 
To
13/04/2007 19:54:24
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01215873
Message ID:
01215900
Views:
13
Tony,

>What I have encountered is that I (having come from the DataSet world) have added my BizObjs - generated nicely by the BLG - to the solution's DataSources. When I place a control on my UserControl - say, mmTextBox - and attempt to set the 'BindingSource' property, nothing appears in the dialog. I imagine that is because my BizObjs of interest are not registered with that UserControl. If I use a non-mm control, setting the "DataSource' property causes Visual Studio to generate a BindingSource for my BizObj and place it in the non-visual designer tray. The BindingSource+BizObj combination, while permitting display of the bound data, does not seem to communicate regarding modifications to that data!

Now that MM .NET 2.4 is released, here is some code from what will be in the next version of MM .NET. For now, try adding this code directly to your project. You should then be able to create user control subclasses of this class that allow you to register business object and bind your user interface controls in the "regular" way:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using OakLeaf.MM.Main.Business;

namespace OakLeaf.MM.Main.Windows.Forms
{
	public class mmUserControl : UserControl
	{

		public virtual mmBaseBusinessObject RegisterBizObj(mmBaseBusinessObject businessObject)
		{
			if (mmAppBase.IsRunning)
			{
				mmBusinessBaseForm ParentForm = mmAppDesktop.FormMgr.GetParentBusinessForm(this);
				if (ParentForm != null)
				{
					ParentForm.RegisterBizObj(businessObject);
				}
			}

			return businessObject;
		}

		public mmUserControl()
		{
			InitializeComponent();
		}
	}
}
Here is an example subclass:
public partial class TestUserControl : mmUserControl
{
	private Orders oOrder;

	public TestUserControl()
	{
		this.oOrder = (Orders)this.RegisterBizObj(new Orders());

		InitializeComponent();

		this.oOrder.GetOrderByOrderID(10248);
	}
}
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