Error while setting Focus in Textbox on a View

  • Thread starter makarand devalekar
  • Start date
M

makarand devalekar

Hi All,
I am quite new to infopath programming.
I have two views with buttons on each of them.
I wish to switch from one view to another view and set the focus on the
textbox control on that view.I am able to achieve it partially i.e. I can
Switch to another view using Switchview method but unable to set the focus in
the textbox in the switched view.

Following is the code snippet which I am trying to implement.

//note: btn1 is the button on first View i.e. "Test1"

public void btn1_Clicked(object sender, ClickedEventArgs e)
{
ViewInfos.SwitchView("Test2");

//// Create XPathNavigator and select field.

string xPath = "//my:Test2";
XPathNavigator mainDOMNavigator =
MainDataSource.CreateNavigator();
XPathNavigator textNodeNavigator =
mainDOMNavigator.SelectSingleNode(xPath, NamespaceManager);

// Select text in specified field.
try
{
//"CTRL1" is the the view context for textbox control in which I
wish to set the focus.

CurrentView.SelectText(textNodeNavigator, "CTRL1");

// CurrentView.SelectNodes(textNodeNavigator);

}
catch (Exception ex)
{

//throw;
}

}

I have tried both CurrentView.selectText(xpathNavigator) and
CurrentView.SelectNodes(xpathNavigator);

But once I reach to this line of the code I get the following exception:
"The specified values for the View.SelectText call are not valid."


I would really appreciate you if anyone of you could help me out.

Thanks ..
~Makarand
 

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