We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Prevent moving to sfdatagrid

Thread ID:





150310 Jan 1,2020 01:12 AM UTC Jan 2,2020 01:34 PM UTC WinForms 1
Tags: SfDataGrid
Tom Krieg
Asked On January 1, 2020 01:12 AM UTC

I have a form which contains a number of  text boxes and comboboxes as well as a sfdatagrid. I want the user to fill in the text and comboboxes first, validate them and if all validation succeeds, and only then, I want the user to be permitted to move to the sfdatagrid and create rows or edit rows. My question is, how can I stop the cursor from moving to the datagrid until a validation flag is set? I can't see a way to do this either in the enter or gotfocus events to prevent the action.

Susmitha Sundar [Syncfusion]
Replied On January 2, 2020 01:34 PM UTC

Hi Tom, 
Thank you for using Syncfusion controls. 
You can prevent the cursor from moving to the SfDataGrid by enable the SfDataGrid.Enable property. Please refer the below code, 
  public Form1() 
            this.sfDataGrid1.DataSource = list; 
            this.sfDataGrid1.Enabled = false; 
  private void ComboBox2_SelectedValueChanged(object sender, EventArgs e) 
      if (comboBox2.SelectedValue.ToString() == "Printer") 
          this.sfDataGrid1.Enabled = true; 
Here, we initially disabled the SfDataGrid and after validating the ComboBox2, enabled the SfDataGrid. You can use this property based on your validation. 
Please check the sample and let us know If we misunderstood anything, please modify the above sample based on your requirement and revert us back.  
Susmitha S 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon