Page 1 of 1

VB to C# ToolClick syntax

PostPosted: Thu Aug 23, 2018 5:30 pm
by DannyC
I am having trouble working out the correct syntax in C# when I have clicked a custom tool added to the ribbon.

In VB it would be
Code: Select all
      AddHandler chequePaymentForm.UltraToolbarsManager1.ToolClick, AddressOf chequePaymentForm_Toolbar_ToolClick
    End Sub
      
   Public Sub chequePaymentForm_Toolbar_ToolClick(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs)
      Dim chequePaymentForm As JiwaCreditorChqPayUI.CreditorChqPay = DirectCast(sender, Infragistics.Win.UltraWinToolbars.UltraToolbarsManager).DockWithinContainer


I am having trouble with the DirectCast line.


Code: Select all
      chequePaymentForm.UltraToolbarsManager1.ToolClick += chequePaymentForm_Toolbar_ToolClick;
   }
   
   public void chequePaymentForm_Toolbar_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
   {
      JiwaCreditorChqPayUI.CreditorChqPay chequePaymentForm =  ?? what do I put here ??;      

Re: VB to C# ToolClick syntax  Topic is solved

PostPosted: Thu Aug 23, 2018 7:05 pm
by SBarnes
Hi Danny

Below is some code I have used in a sales order form to do what you are looking to do which should give you the idea, basically the sender will be the UltraToolbarsManager and from there DockWithinContainer will give you the form that owns the UltraToolbarsManager.


Code: Select all
 Infragistics.Win.UltraWinToolbars.UltraToolbarsManager toolbar = (Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)sender;
JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm salesform = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)toolbar.DockWithinContainer;