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.
Syncfusion Feedback

Localizing a message box in GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

55158 Jan 24,2007 03:07 PM UTC Feb 6,2007 03:49 PM UTC Windows Forms 10
loading
Tags: GridControl
Ronnie Kleinfeld
Asked On January 24, 2007 03:07 PM UTC

Hi,

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

Thanks,
Ronnie

contacts errormessage.zip

Administrator [Syncfusion]
Replied On 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

Tom Hollander
Replied On 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.

Tom Hollander
Replied On 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 .

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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 ...".

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Tom Hollander
Replied On January 30, 2007 07:29 AM UTC

just what I was looking for !

thanks,
Tom

Tom Hollander
Replied On 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

Administrator [Syncfusion]
Replied On 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

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.

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

;