Hi All,
I am facing a problem with Disabling of a custom tool bar button. Actually i am making "Enabled" property of my custom tool bar button to "false". But it is not disabling. If i made "Visible" property of that toolbar button to "false", then it's working means the control is in-visible. But my actual requirement is i should disable the button not as in-visible.
Can any one please help me. It's very urgent. Thanks in advance.
Below is my template and code details:
In My Template manifest.xsn file, below is the code for my custom tool bar.
<xsf:toolbar caption="Custom ToolBar" name="CustomToolbar">
<xsf:button name="btnSaveToDatabase" icon="SaveToDatabase.gif" tooltip="Save To Database" showIf="immediate"></xsf:button>
<xsf:button name="btnConvertToWord" tooltip="Show In Word" icon="Word.gif"></xsf:button>
<xsf:button action="btnRemoveApprover" caption="Remove Approver" tooltip="Remove Approver"></xsf:button>
<xsf:button action="btnAddApprover" caption="Add Approver" tooltip="Add Approver"></xsf:button>
</xsf:toolbar>
Based on the current position in the form i need to disable some of the custom tool basr buttons, say for example "btnRemoveApprover and btnAddApprover". And these buttons i am using to Add/Delete a row to myApprovers table.
To get the current selected section from the form i raised an OnContextChanged event.
below is my code:
[InfoPathEventHandler(EventType=InfoPathEventType.OnContextChange)]
public void OnContextChange(DocContextChangeEvent e){
CommandBars objCommandBars = UnwrapCommandbarsObject((ObjectWrapper)thisXDocument.View.Window.CommandBars);CommandBar customToolBar = null;
try
{
customToolBar = objCommandBars["CustomToolBar"];
}
catch
{
return;
}
if (e.Context.nodeName != "my:Approvers") // my:Approvers is the section for adding/deleting approvers in my form.
{
customToolBar.Controls[3].Enabled = false;
customToolBar.Controls[4].Enabled = false;
}
else
{
customToolBar.Controls[3].Enabled = true;
customToolBar.Controls[4].Enabled = true;
}
}
Regards,
Kavitha