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.
Unfortunately, activation email could not send to your email. Please try again.

Column validating coding

Thread ID:

Created:

Updated:

Platform:

Replies:

124880 Jul 6,2016 01:07 AM Jul 12,2016 03:14 AM Windows Forms 11
loading
Tags: GridGroupingControl
Michael K
Asked On July 6, 2016 01:07 AM

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

Michael K
Replied On July 6, 2016 03:42 AM

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

Piruthiviraj Malaimelraj [Syncfusion]
Replied On July 6, 2016 02:43 PM

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 


Michael K
Replied On July 7, 2016 12:35 AM

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

Anish George [Syncfusion]
Replied On July 7, 2016 01:34 PM

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. 


Michael K
Replied On July 7, 2016 05:59 PM

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

Michael K
Replied On July 8, 2016 01:01 AM

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

Anish George [Syncfusion]
Replied On July 8, 2016 09:38 AM

  
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:  
https://www.syncfusion.com/support/directtrac/incidents/ 
 
Regards, 
Anish. 


Michael K
Replied On July 8, 2016 09:59 AM

Dear Anish :

Your message well note with thanks

Michael

Anish George [Syncfusion]
Replied On July 11, 2016 08:23 AM

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 


Michael K
Replied On July 11, 2016 09:43 AM

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

Venkatesh Sundaram [Syncfusion]
Replied On July 12, 2016 03:14 AM

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


CONFIRMATION

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.

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.

;