set focus on propertygrid control's propertyitem

Good day! I'm trying to set up a condition on a propertygrid where if a regex is not match it will not leave the propertyitem on propertygrid

  if (Regex Condition)

                    {

                        PropertyGrid PropertyGrid = sender as PropertyGrid;

                        TextBox Name = SelectedPropertyItem.PropertyEditor as TextBox;

                        Name.Background = Brushes.Red;

                        Name.Focus();

                        MessageBox.Show("Invalid Regex");

                    }

but on this code, it seems like the .Focus() doesn't seem to work. Is there a way to programmatically set focus on a propertygrid's propertyitem?

Thank you!


1 Reply

GT Gokul Thanudhas Syncfusion Team April 28, 2022 08:25 AM UTC

Hi Lowell,


We unable to reproduce the issue from our end. We have tried to set focus to the propertyItem's editor in SelectedPropertyItemChanged event. Please refer the sample and video from the attached file for your reference.


If we misunderstood your query, please provide sample or more information about the requirement.So, it will be helpful to prompt the solution further.


Regards,

Gokul.


Attachment: PropertyGrid_Focus_a853047.zip

Loader.
Up arrow icon