Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MmButtonNew.BindingSource
Message
De
09/09/2004 16:14:16
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
MmButtonNew.BindingSource
Divers
Thread ID:
00940818
Message ID:
00940818
Vues:
73
I am creating a base form (class) for a WinForms form. I call it bxCardForm (bx = client name).

My form is parallel to, and similar to, mmMaintenanceForm. The main difference is that my form does not have a tab control and a list. For now, let's assume that all navigation is done via the navigation toolbar.

I will inherit from my bxCardForm to create specific forms for my tables (e.g., StoreForm).

On my base form, bxCardForm, I have put four buttons:
protected OakLeaf.MM.Main.Windows.Forms.mmButtonDelete btnDelete;
protected OakLeaf.MM.Main.Windows.Forms.mmButtonNew btnNew;
protected OakLeaf.MM.Main.Windows.Forms.mmButtonSave btnSave;
protected OakLeaf.MM.Main.Windows.Forms.mmButtonCancel btnCancel;
My question is: Given that there will only be one business object on most of the forms I will subclass from bxCardForm, is there any point in setting the BindingSource property of these four buttons on the table-specific forms?

Everything seemed to work fine before I set the BindingSource property, and setting it didn't seem to change any behavior.

The reason I ask is, I copied the following code for btnNew out of mmMaintenanceForm and put it in bxCardForm:
protected virtual void btnNew_Click(object sender, System.EventArgs e)
{
	// Only navigate if the navigation controls' business object
	// is the same as the object we're adding a DataRow to
	if (this.NavControl != null &&
		(this.GetBizObj(this.NavControl.BindingSource) == 
		this.btnNew.GetBizObj()))
	{

		if (btnNew.GetBizObj(this) == 
			this.GetBizObj(this.NavControl.BindingSource))
		{
			// Determine if bound to a DataTable or DataView	
			string TableName, ViewName;
			mmBindingStrategyBase.GetBindingSource(this.btnNew.BindingSourceMember,
				out TableName, out ViewName);
			if (mmString.Empty(ViewName))
				// Bound to a DataTable...Navigate to the last record
				this.NavigateData(mmNavigate.Last, false);
			else
				// Bound to a DataView...Navigate to the first record
				this.NavigateData(mmNavigate.First, false);
		}
	}
}
(I removed the call to this.SelectEditPage(), which is not relevant since I don't have "list" and "properies" tabs on my form.)

While debugging, I noticed that after this line runs:
mmBindingStrategyBase.GetBindingSource(this.btnNew.BindingSourceMember,
	out TableName, out ViewName);
...the strings TableName and ViewName are both empty. So, I figured setting BindingSource might be required. (But setting it to the table of the primary business object didn't do anything: TableName and ViewName both still come out empty.)

Two follow-on questions:

1) Should I be concerned that TableName and ViewName are both empty after the call to mmBindingStrategyBase.GetBindingSource?

2) Was it appropriate for me to copy the above btnNew block of code into my bxCardForm?

Thanks,
Ric
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform