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

Localizing a message box in GridGroupingControl

Hi,

I need to localize this message.
Where is the property for this message text?

Thanks,
Ronnie

contacts errormessage.zip

10 Replies

AD Administrator Syncfusion Team January 24, 2007 03:23 PM UTC

Hi Ronnie,

In the Essential Studio 4.2, We have newly added a TableControlCurrentCellErrorMessage event which you can handle and display your own custom message box whenever the grids CurrentCell.DisplayWarningText (as a result of some kind of validation error) is called. Here is a code snippet.

//hook the event
gridGroupingControl1.TableControlCurrentCellErrorMessage += new GridTableControlCurrentCellErrorMessageEventHandler(gridGroupingControl1_TableControlCurrentCellErrorMessage);

void gridGroupingControl1_TableControlCurrentCellErrorMessage(object sender, GridTableControlCurrentCellErrorMessageEventArgs e)
{
e.Text = "Your localized text here..";
}

Best Regards,
Haneef


TH Tom Hollander January 25, 2007 11:15 AM UTC

hi,

I tried using the event.
The problem still remains as the event does not fire when submitting an empty cell that has a NOT NULL constraint.
In order to reproduce the problem:
1. bind the grid to a typed Dataset.
2. mark all fields as not null , except for one.
3. when inputting data to the grid, set a value in the cell that accepts null values and press the enter key.
you shuld get an error
message : "SaveRecord :Column 'myColumn' does not allow nulls."

This is the error message we need to localize.

As I mentioned, the TableControlCurrentCellErrorMessage event does not solve the problem as the current cell has valid data. the error is raised at a later stage.


TH Tom Hollander January 25, 2007 11:22 AM UTC

Also , I noticed that the GridTableControlCurrentCellErrorMessageEventArgs
does not have a Text property .
The syncfusion version we have is 4.2 .


AD Administrator Syncfusion Team January 25, 2007 06:53 PM UTC

Hi Tom,

Issue 1:

One way you can do this by handling the TableControlCurrentCellAcceptedChanges event and call dataRow.EndEdit method to show the custom message box in a cell. Here is a code snippet

private void gridGroupingControl1_TableControlCurrentCellAcceptedChanges(object sender, GridTableControlCancelEventArgs e)
{
try
{
DataRowView row = ((DataRowView)e.TableControl.Table.CurrentRecord.GetData());
if( row != null)
row.Row.EndEdit();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"Your Message" );
}
}

Please refer to the attached sample for more details.
GGC_Sample.zip

Issue 2: Also , I noticed that the GridTableControlCurrentCellErrorMessageEventArgs does not have a Text property . The syncfusion version we have is 4.2 .

>>> Sorry for the inconvenience caused. You can use the e.Inner.Text property to set the localizied text of the MessageBox.

Best Regards,
Haneef


AD Administrator Syncfusion Team January 28, 2007 08:14 AM UTC

Thanks for the quick response...

what you suggested doesn't solve the case of submitting null values into non nullable cells in the grouping control.

The non nullable cells are defined at the typed dataset level and the error message we get as a result of submitting null values is raised after the CurrentCellAcceptedChanges event.

What happened in your example when i tried it in my project is that the condition: if(row!= null) was always true even when non nullable cell weren't given values. so I didn't get the desired effect of overriding / localizing the current controls message of "SaveRecord ...".


AD Administrator Syncfusion Team January 29, 2007 08:14 PM UTC

Hi Tom,

We were not able to reproduce the issue here. Is it possible for you to upload us a sample or modify the attached sample to reproduce the issue here? This will help us to analyse the issue further.

Here is a sample.
GGC_Sample.zip

Best Regards,
Haneef


AD Administrator Syncfusion Team January 29, 2007 10:12 PM UTC

Hi Tom,

One way you can do this by handling the ExceptionRaised event and set the e.Cancel = true; to cancel it.

private void gridGroupingControl1_ExceptionRaised(object sender, ExceptionRaisedEventArgs e)
{
//If you want to show the MessageBox then call MessageBox.Show method explictly.
//If you want to set default error message then call the SetErrorText(sender, e.Exception.Message);
SetErrorText(sender,"ExceptionRaised event your Text");
e.Cancel = true;
}

private void SetErrorText(object sender, string ErrorMsg)
{
GridGroupingControl grid = sender as GridGroupingControl;
foreach (CurrentRecordProperty prop in grid.Table.CurrentRecordManager.Properties)
{
if (prop.IsError)
prop.Exception = new Exception(ErrorMsg, prop.Exception.InnerException);
}
}

Please refer to the attached sample for implementation.
ModifiedGGC_Sample_3ad9c9c3.zip

Let me know if you are looking something different.

Best Regards,
Haneef


TH Tom Hollander January 30, 2007 07:29 AM UTC

just what I was looking for !

thanks,
Tom


TH Tom Hollander February 6, 2007 09:28 AM UTC

Hi Haneef ,

Im still having some problems with this issue.
When using the exception reaised event , the event fires every time a user clicks a cell in the same row he is editing.
This causes the "Empty value" messaebox to pop up while editing the row.

How can I prevent this from happening? I need the messagebox to pop up only when the user is done editing the current row and there is a value missing in a non null cell.

best regards
Tom


AD Administrator Syncfusion Team February 6, 2007 03:49 PM UTC

Hi Tom,

I am not sure of what be might be causing this strange behavior without a working sample. I have tested this issue in the attached sample with Essentail studio V.4.x. I was not able to reproduce the issue. Maybe I am not following the steps that you are doing. Please post us a sample showing this problem or modify the attached samples to reproduce the problem, which will help me to find the issue and resolve this.

Sample : ExceptionRaisedSample

Thanks for your patience.

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon