سؤال

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?

هل كانت مفيدة؟

المحلول

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
   }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top