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
close icon

Prevent moving to sfdatagrid

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.

1 Reply

SS Susmitha Sundar Syncfusion Team 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, 
 
C#: 
 
  public Form1() 
        { 
            InitializeComponent(); 
 
 
            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.  
 
Regards, 
Susmitha S 


Loader.
Live Chat Icon For mobile
Up arrow icon