AD
Administrator
Syncfusion Team
July 26, 2006 12:27 PM UTC
Hi Thomas,
You need to subscribe the TableControlCurrentCellValidating event and set e.Inner.Cancel flag to true for invalid Format. Please find the code snippet below.
private void gridGroupingControl1_TableControlCurrentCellValidating(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e)
{
if(!ValidFormat())
{
//After cancel the validate event MessageBox disappered
e.Inner.Cancel = true;
//If you want to change the MessageBox, Call MessageBox.Show() method.
}
}
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
July 26, 2006 12:56 PM UTC
Hi,
thanks for your response, this just solves a part of my problem. With your code example I can disable the MessageBox and handle the error by myself. But I want to recognize that a format specifier is invalid just in the moment when I set it for a column.
Any ideas?
Cheers,
Thomas
AD
Administrator
Syncfusion Team
July 27, 2006 05:26 AM UTC
Hi Prathima,
There is a special formatting event that you could use to control the formatting. The event is QueryCellFormattedText. Below are some snippets that show how you could cancel the invalid format.
//hook the event
this.gridDataBoundGrid1.Model.QueryCellFormattedText += new GridCellTextEventHandler(grid_QueryCellFormattedText);
//the handler
private void grid_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
try
{
e.Style.ApplyFormattedText(e.Style.Text);
}
catch
{
e.Handled = true;
Console.WriteLine("welcome");
}
}
To resolve the Bold Text with shade apperance in the invalid format cell, You need to subscribe the TableControlDrawCellDisplayText and set e.Inner.Cancel = true for invalid format cell.
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGC_ContextMenu_17e6e970.zip
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
July 27, 2006 05:52 AM UTC
Hi Thomas,
My apologies for addressing to the wrong person, it was meant for you
There is a special formatting event that you could use to control the formatting. The event is QueryCellFormattedText. Below are some snippets that show how you could cancel the invalid format.
//hook the event
this.gridDataBoundGrid1.Model.QueryCellFormattedText += new GridCellTextEventHandler(grid_QueryCellFormattedText);
//the handler
private void grid_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
try
{
e.Style.ApplyFormattedText(e.Style.Text);
}
catch
{
e.Handled = true;
Console.WriteLine("welcome");
}
}
To resolve the Bold Text with shade apperance in the invalid format cell, You need to subscribe the TableControlDrawCellDisplayText and set e.Inner.Cancel = true for invalid format cell.
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGC_ContextMenu_17e6e970.zip
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
July 27, 2006 06:21 AM UTC
Thank''s it just works.
AD
Administrator
Syncfusion Team
July 27, 2006 09:01 AM UTC
Hmm sorry, I think I was too fast. When I set the a new format string (which is wron) the event is called:
void grGrCo_SeqDef_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
try
{
e.Style.ApplyFormattedText(e.Style.Text);
}
catch
{
e.Handled = true;
MessageBox.Show("Error here");
}
}
But the try block runs thru without getting an exception. The whole column content is however bold. And when I click into a cell in that column I still get the "format specifier error". I am also not able to avoid the bold font.
Any ideas
AD
Administrator
Syncfusion Team
July 27, 2006 09:19 AM UTC
Hi,
Sorry for the inconvenience. The sample works fine for me, and I am not able to see the mentioned issue here. I have attached the sample here. Can you able to see the issue in the attached sample? Or can you please tell me how to reproduce the issue in the attached sample so that we can get back soon with a solution at the earliest.
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGC_ContextMenu_17e6e970.zip
Please let me know about the current version of Essential Studio/.Net FrameWork you are using.
Thanks for your patience.
Regards,
Haneef
AD
Administrator
Syncfusion Team
July 27, 2006 09:48 AM UTC
Hi,
sorry I forgot to add the sample where you can reproduce my issues. Now it''s attached.
I have added a new menu item called "Format General". Now when you click on Col1 -> "FormatGeneral" a new dialog box appears. Here you have to enter a wrong specifier like "U". Click OK and you will see the bold font. Now when you click in a cell of that column you get the error mentioned above. My aim is to check the specifier and inform the user instead of the bold font and the error. Do you know how to handle this.
Kind regards
GGC_ContextMenu.zip
AD
Administrator
Syncfusion Team
July 27, 2006 10:31 AM UTC
Hi,
Please try this code to resolve this issue.
try
{
Syncfusion.Styles.ValueConvert.FormatValue(e.Style.CellValue, e.Style.CellValueType, e.Style.Format, e.Style.CultureInfo, e.Style.CurrencyEdit.NumberFormatInfoObject);
}
catch
{
e.Handled = true;
Console.WriteLine("welcome");
}
Here is a modified sample.
http://www.syncfusion.com/Support/user/uploads/GGC_ContextMenu_502762fb.zip
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
July 27, 2006 11:01 AM UTC
Hmm,
I can''t download your sample - can you doublecheck please?
AD
Administrator
Syncfusion Team
July 27, 2006 11:08 AM UTC
Hi,
Sorry for the incovenience caused.
Here is a link.
http://www.syncfusion.com/Support/user/uploads/GGC_ContextMenu_3d88142.zip
Thanks for your patience.
Regards,
Haneef
AD
Administrator
Syncfusion Team
July 28, 2006 07:22 AM UTC
Hi,
now the whole column is empty when I enter a wrong formatspecifier isn''t it. I wanna set an errorprovider for the column header of that column which informs the user about the wrong format specifier. If the column is empty - the user doesn''t know what''s wrong. Is it possible to set a column header error provider if the format specifier is wrong?
Thank you very much for your help. Syncfusion has the best support I know !!
AD
Administrator
Syncfusion Team
July 28, 2006 10:51 AM UTC
Hi,
You can handle the TableControlCellDrawn to draw the error icon in a invalid cell. Please find the code snippet below.
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if (IsInValid && style.TableCellIdentity.Column != null && style.TableCellIdentity.Column.Name == ErrorColumn)
{
// Highlight error column
Brush br = new SolidBrush(Color.FromArgb(64, Color.Red));
e.Inner.Graphics.FillRectangle(br, e.Inner.Bounds);
br.Dispose();
try
{
e.Inner.Cancel = true;
Rectangle iconBounds = Rectangle.FromLTRB(e.Inner.Bounds.Right - 15, e.Inner.Bounds.Top, e.Inner.Bounds.Right, e.Inner.Bounds.Bottom);
iconBounds.Offset(-2, 0);
IconPainter.PaintIcon(e.Inner.Graphics, iconBounds, Point.Empty, "SFERROR.BMP", Color.Red);
}
catch
{ }
}
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGC_ContextMenu_98974cfe.zip
For more details about the drawing the Erroricon in a cell, See the TestErrorProvider browser sample.
\Syncfusion\Essential Studio\4.2.0.37\windows\Grid.Grouping.Windows\Samples\TestErrorProvider
Thanks,
Haneef
YX
YUAN Xiaorong
replied to Administrator
March 1, 2018 03:30 PM UTC
Hmm,
I can''t download your sample - can you doublecheck please?
By posting my answer, I agree to the privacy policy and terms of service.
AR
Arulpriya Ramalingam
Syncfusion Team
March 2, 2018 05:25 AM UTC
Hi Yuan,
Thanks for the update.
Please let us know whether you need any further assistance.
Arulpriya