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

Column validating coding

Hi :

today, I try to write a code to do some value validating, I have choose the event  (TableControlCurrentCellEditingComplete) of GridGroupingControl to do this function
My Grid information is that
Column[1] - studentcode
Column[2] - studentname
Column[3] - classnumber

The code as below

 Private void gcc_TableControlCurrentCellEditingComplete(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventArgs e)
        {
string _value = gcc.Table.CurrentRecord("studentcode").ToString()
if (validerror(_value)) {
gcc.TableControl.CurrentCell.MoveTo(e.TableControl.CurrentCell.RowIndex, 1, GridSetCurrentCellOptions.SetFocus)
e.TableControl.SelectRecords.Clear()
}
          
        }

However, it can't work, the cursor always locate Column[2], can I know how to go back Column [1] ?

Thanks

Michael

11 Replies

MK Michael K July 6, 2016 07:42 AM UTC

Hi :

For one more case, while the GCC allow user add and edit, if Column[1] studentcode (locate in add row) data is not valid, how can I prevent the user to add row to prevent the GCC to add invalid row



Michael


PM Piruthiviraj Malaimelraj Syncfusion Team July 6, 2016 06:43 PM UTC

Hi Michael, 
 
Thank you for using Syncfusion products. 
 
Query 
Solution 
Move the current cell focus. 
We had created the simple as per your scenario and the current cell focus has been changed via MoveTo method of CurrentCell. Please refer the attached sample and please let us know if we missed anything in your customization. It would be more helpful for us to provide the exact solution at the earliest. 
 How can I prevent the user to add row to prevent the GCC to add invalid row 
We had analyzed your query in our end and need some additional details regarding the validation done in your current cell. The GridGroupingControl have built-in support for validating the current cell value by enabling the property ShowErrorIcon, ShowErrorMessageBox via the CurrentCell property. This will restrict the invalid cell value being entered in the cell. Please let us know if we misunderstood anything. 
 
Sample link 
 
Regards, 
Piruthiviraj 



MK Michael K July 7, 2016 04:35 AM UTC

Dear Piruthiviraj:

Thanks for your advice, and I have downloaded your example , and I can use your sample to further explain
Issue 1.
 TableControlCurrentCellEditingComplete exception found
When I open your sample, I use mouse click the catalog ID (in 3rd row ) and then click on another catalog (in 4th row), it have exception 
which show this.gridGroupingControl1.Table.CurrentRecord is null, is this normal (as I think it should not be null)


Issue 2 :
Can I restrict user to add row when the CategoryName is string.empty or (some other condition), it mean user can input value in other cells in the (add row), but, when the GCC attempt to add row and check he CategoryName  value is string.empty, it will cancel.

Issue 3 :
I have add the code in the TableControlCurrentCellEditingComplete  as below

  if (this.gridGroupingControl1.Table.CurrentRecord["Description"] != null)
                {
          
                    int value = (int)this.gridGroupingControl1.Table.CurrentRecord["Description"];
                    if (value ==999)
                    {
                        Console.WriteLine("Lock cell");
                        this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(e.TableControl.CurrentCell.RowIndex, 1, GridSetCurrentCellOptions.SetFocus);
                    }
                }

The result is that , it may go to error exception on issue 1, In some case, Even the this.gridGroupingControl1.Table.CurrentRecord is not null, the program haveoutput "lock cell", the input cursor still jump into CategoryID column

Could you help to solve above 3 issues ?

Thanks

Michael


AG Anish George Syncfusion Team July 7, 2016 05:34 PM UTC

Hi Michael 

Thank you for update. 

Query 
Response 
this.gridGroupingControl1.Table.CurrentRecord is null, 
When editing is completed for the current record and if another record has been clicked then at that moment no record is been edited and Table.CurrentRecord becomes null. Hence we request you to put null check condition. Please refer the sample for more information. 
Can I restrict user to add row when the CategoryName is string.empty 
Please make use of the below code to achieve your requirement. Please refer the below sample for more information. 
 
if (this.gridGroupingControl1.Table.CurrentRecord != null && this.gridGroupingControl1.Table.CurrentRecord["CategoryName"] != null) 
{ 
   string value = this.gridGroupingControl1.Table.CurrentRecord["CategoryName"].ToString(); 
    if(string.IsNullOrEmpty(value)) 
    { 
       value = "Value is empty"; 
    } 
} 

The result is that , it may go to error exception on issue 1 
As requested before we request you to put null check condition to overcome this issue. Please refer the below sample and let us know if you still experience any issues. 


Please let us know if you need any further assistance. 

Regards, 
Anish. 



MK Michael K July 7, 2016 09:59 PM UTC

Hi Anish:

Thanks for your example
After run your example code, and test, only issue 1 have fix, issue 2 and issue 3 still appear,that mean
Issue 2 : Value empty in CategoryName allow me to add row 
Issue 3 : Value (999) input in Description allow me to enter the next column

Attach picture.zip is my reference

Could you advice about it

Thanks

Michael


Attachment: Test_result_screen_capture_6dc047ea.zip


MK Michael K July 8, 2016 05:01 AM UTC

Hi Anish:

Now, I have upload your sample code, modify the data structure (just correct data type, and column, under the form.cs, I have add the comment and describe the problem
Can you check for it and advice the good way to solve 

Thanks

Michael

Attachment: WorkSamplemycase20160708_57c15bd6.zip


AG Anish George Syncfusion Team July 8, 2016 01:38 PM UTC

  
Hi Michael, 

  

Thank you for your update. 

                                

We are able to see your requirements. We request you to create  a Direc-Trac incident regarding this so that our dedicated engineers will work in this and will give you a quick solution and for better documentation. You can create Direc-Trac incidents in the below link.  
 
DT-link:  
 
Regards, 
Anish. 



MK Michael K July 8, 2016 01:59 PM UTC

Dear Anish :

Your message well note with thanks

Michael


AG Anish George Syncfusion Team July 11, 2016 12:23 PM UTC

Hi Michael, 

Thank you for your update. 

We request you to post further updates in the incident #160127. Please follow up further queries in that incident. 

Regards, 
Anish 



MK Michael K July 11, 2016 01:43 PM UTC

Dear Anish :

Sure, let me act as end user and try to input the grid and also attempt to do some tricky input,
If I have any update , will let you know
Thanks

Michael


VS Venkatesh Sundaram Syncfusion Team July 12, 2016 07:14 AM UTC

Hi Michael, 
  
Thanks for the update. Please let us know if you need any further assistance. 
  
Regards, 
Venkat. 
  


Loader.
Live Chat Icon For mobile
Up arrow icon