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.

CellErrorMessage

Thread ID:

Created:

Updated:

Platform:

Replies:

57625 Mar 7,2007 09:13 AM May 8,2007 05:53 PM Windows Forms 6
loading
Tags: Grouping
Aleksander Sadovnikov
Asked On March 7, 2007 09:13 AM

Can you help me. How can I change the displayed error message for an cell. For example I have column type of byte, when I enter some string, for example "dfg" I will see that cell becomes red and error message like "dgf is not a valid value for Byte" How can I change displayed error message for cell, or to which event I must subscribe to disable this.

Administrator [Syncfusion]
Replied On March 7, 2007 10:57 AM

Hi Alexander,

You can subscribe the 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)
{
MessageBox.Show("Your Text Here");
e.Inner.Cancel = true;
}

Best Regards,
Haneef

Aleksander Sadovnikov
Replied On March 9, 2007 02:54 AM

Thnx, but I need to change not an message box, but error message that is displayed in cell.

Thank you for reply.

>Hi Alexander,

You can subscribe the 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)
{
MessageBox.Show("Your Text Here");
e.Inner.Cancel = true;
}

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On March 9, 2007 12:48 PM

Hi Alexander,

You catch TableControlCurrentCellErrorMessage event and set e.TableControl.CurrentCell.ErrorMessage to be the string you want displayed. Please try the suggestion and let me know if this.

private void gridGroupingControl1_TableControlCurrentCellErrorMessage(object sender, GridTableControlCurrentCellErrorMessageEventArgs e)
{
e.TableControl.CurrentCell.ErrorMessage = "welcome";
}

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 12, 2007 11:17 AM

Thnx. But it not working.
I try this
private void gridGroupingControl1_TableControlCurrentCellErrorMessage(object sender, GridTableControlCurrentCellErrorMessageEventArgs e)
{
GridColumnDescriptor columDesc = e.TableControl.Table.GetColumnDescriptorAt(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex);

if (columDesc == null)
{
e.Inner.Cancel = false;
return;
}

string columnName = null;
if (columDesc != null)
{
columnName = columDesc.Name;
}

DataColumn col = _localDataTable.Columns[columnName];

string errMessage = GetCellErrorMessage(e.TableControl.CurrentCell, col.GetType());
if (errMessage.Length > 0)
{
//e.Inner.Cancel = true;
e.TableControl.CurrentCell.ErrorMessage = errMessage;
e.TableControl.CurrentCell.Exception = new Exception(errMessage);
//MessageBox.Show(errMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
e.Inner.Cancel = false;
}

But error message is not that i`m trying to set. It still the same. Can you help me with this.


>Hi Alexander,

You catch TableControlCurrentCellErrorMessage event and set e.TableControl.CurrentCell.ErrorMessage to be the string you want displayed. Please try the suggestion and let me know if this.

private void gridGroupingControl1_TableControlCurrentCellErrorMessage(object sender, GridTableControlCurrentCellErrorMessageEventArgs e)
{
e.TableControl.CurrentCell.ErrorMessage = "welcome";
}

Best regards,
Haneef

Rocky Tatlay
Replied On May 4, 2007 01:36 PM

Hello,

I looked at the examples and decided to use the GridDrawCellEventHandler. It works well except for some unexpected results. I’m using a grouping grid control and the errors icons will not draw on the header rows when the records are not expanded. Once expanded, the error icons draw on the parent records only once you enter the child records. They will disappear if you collapse the group. The child records errors draw perfectly but the parent error icons appear and disappear unexpectedly. I’m using separate event handlers for the parent and child tables.

groupinggridcntrl.GetTableControl("parenttable").DrawCell +=new GridDrawCellEventHandler(groupinggridcntrl_DrawParentErrors);

groupinggridcntrl.GetTableControl("childtable").DrawCell +=new GridDrawCellEventHandler(groupinggridcntrl_DrawChildErrors);

Any ideas how to get the parent rows to draw errors when they should?

Here’s a code snippet of the event:

void groupinggridcntrl_DrawParentErrors(object sender, GridDrawCellEventArgs e)
{
GridTableControl tc = sender as GridTableControl;
GridTableCellStyleInfo style = tc.GetTableViewStyleInfo(e.RowIndex, e.ColIndex) as GridTableCellStyleInfo;
Record r = style.TableCellIdentity.DisplayElement.GetRecord();

if (style != null
&& style.TableCellIdentity.Column != null
&& r != null)
{
col = style.TableCellIdentity.Column.Name;

//code for determinig if error should occur on cells

hashKey = hash_HdrID + hash_DtlID + col;

if (errHash.ContainsKey(hashKey))
{
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
Icon failureIcon = SystemIcons.Error;

Rectangle iRect = new Rectangle(new Point(e.Bounds.Right - 20, e.Bounds.Top), new Size(20, e.Bounds.Height));
e.Graphics.DrawIcon(failureIcon, iRect);
e.Cancel = true;
}
}
}

Rajagopal [Syncfusion]
Replied On May 8, 2007 05:53 PM

Hi Rocko,

For displaying custom error messages in grid handling the TableControlCurrentCellValidating/TableControlCurrentCellErrorMessage events should be fine. Please try the below sample that works in showing custom error message properly.

Here is a sample http://www.syncfusion.com/Support/user/uploads/GGC_CustomErrorMessage_acf1f550.zip

Let us know if this helps.
Regards,
Rajagopal

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.

;