Setting Controls' Visibility on form load

R

Raphael Iloh

Hi all,
I've got a button on an InfoPath form and I'd like the button to be disabled
by default when the form loads, how do I achieve this?

I can set the button's status (enabled/disabled) using the value of another
field on the form but this happens after the form had loaded. What I really
want to achieve is to have the button disabled by default once the form loads.

Best regards,

Raphael Iloh.
 
S

SSA

Create a hidden field in your form and add a rule, e.g, if the hidden field
is blank then hide another control else display it. The hidden field will
always be blank by default so your control will be disabled when the form
loads. You can also do this programmatically:

public void InternalStartup()
{
EventManager.FormEvents.Loading += new
LoadingEventHandler(FormEvents_Loading);

}

private void FormEvents_Loading(object sender, LoadingEventArgs e)
{
XPathNavigator _DOM = this.MainDataSource.CreateNavigator();
XPathNavigator Option =
_DOM.SelectSingleNode("/my:myFields/my:yourfieldname", this.NamespaceManager);

Option.SetValue("anyvalue");
}

This code will set the hidden field's value which will enable the button
according to the rule that you applied in your form. Similarly, you can clear
the field to disable the button.

Hope this helps

http://sharepointblogs.com/ssa
 
R

Raphael Iloh

Hi SSA,
Unfortuantely your response does not answer my question; I can create a new
field alright (either via InfoPath UI or programmatically) but that does not
give me any form of handle/access to the button. Again, setting rules on a
field to control the availability (or otherwise) of a button control doesn't
appear possible as the button isn't listed as a filed item.

My question again is: how do I disable a button by default once an InfoPath
form loads? It needs to be disabled prior to the very first user-action; This
probably could be done in the onload event of the form but how do I get a
handle/access to the BUTTON (or its properties) from the codes?

Best regards,

Raphael.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top