Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New button on Business maintenance form
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01149381
Message ID:
01151134
Views:
32
>Where is the best place to set these properties for the toolstrip buttons?

I'm getting an error: Unable to cast object of type 'OakLeaf.MM.Main.Windows.Forms.mmToolStripButton' to type 'System.Windows.Forms.Control'.

I tried:
protected override void CreateNavToolBar()
{
  // create the NavToolBar
  base.CreateNavToolBar();
  
  // then set the bindings
  int ButtonCount = NavToolBar.Items.Count;

  for (int i = 0; i < ButtonCount; i++)
  {
     mmToolStripButton b = (mmToolStripButton)NavToolBar.Items[i];

     // using new form mmDataGridView property NavDataGrid 
     // set to the the same DataGrid as NavControl
     // 1) to get binding source here
     // 2) to get DataView for checking order in NavigateNew()

     b.BindingSource = this.NavDataGrid.BindingSource;
     b.BindingSourceMember = this.NavDataGrid.BindingSourceMember; // causes error
  }
}
The error happens here:
/// <summary>
/// Binds the simple binding control to the specified DataSet and DataTable
/// </summary>
/// <param name="mmControl">Control to be bound</param>
/// <param name="ds">DataSet</param>
/// <param name="tableName">DataTable</param>
/// <param name="fieldName">Field name</param>
/// <param name="bizObj">Business object associated with the control</param>
public static void BindData(ImmBindingSimple mmControl, DataSet ds, string tableName, string fieldName, mmBusinessObject bizObj)
{
  // Cast the control to System.Windows.Forms.Control
  Control control = (Control)mmControl;  // <---- error!!!
Previous
Reply
Map
View

Click here to load this message in the networking platform