Question

I have a DataForm bound to a simple object that has some text fields. The DataForm correctly auto generates a TextBox for each of the string fields. From code I now need to set the focus to one of those generated TextBox elemetns. How do you get the generated element from the DataForm so I can set focus to it?

Was it helpful?

Solution

Use AutoGeneratingField event of DataForm.
Here is example how to get property with name ID

   
void dataForm1_AutoGeneratingField(object sender, DataFormAutoGeneratingFieldEventArgs e)
{
   if (e.PropertyName == "ID")
   {
       // set focus
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top