hi,
I am using griddata bound control.
In my grid first two columns are double,If i enter other then double value, It will popup error msg.
How do i catch that msg..?
i am using following event, is it correct.
private void sgbDetailedHistory_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e) {
GridCurrentCell cc = this.sgbDetailedHistory.CurrentCell;
object oldValue = this.sgbDetailedHistory[cc.RowIndex, cc.ColIndex].CellValue;
string newValue = cc.Renderer.ControlText;
if(cc.ColIndex >= 1 && cc.ColIndex <= 6) {
double d;
if (newValue.Trim() != "") {
if(!double.TryParse(newValue, System.Globalization.NumberStyles.Any, null, out d)) {
e.Cancel = true;
cc.ErrorMessage = string.Format("Invalid double value");
}
}
}
}
I have one more idea like field level validation.
Right now i allow the user to enter only numbers key, minus and decimal point.
Problem here is user can enter more then one decimal point and minus.
Is there any way to restrict this(more then one decimal point and minus)
also.
Any idea about mask property.To restrict that.
Thanks, Anna
AD
Administrator
Syncfusion Team
August 25, 2005 07:11 AM UTC
Your CurrentCellvalidating seems OK to me. Is it not working for you?
If you want to prevent your user from typeing 2 decoaml points, then one way to do this is to use the CurrentCellValidateString event. The event args will have a e.Text member that ois the proposed new string. This event is hit keystroke by keystroke. You could use similar code to that you have in CurrentCellValidating to try to validate e.Text in this CurrentCellValidateString event.
AS
Anna Srinivasan
August 25, 2005 11:41 AM UTC
Hi,
I am using currentcellvalidatingstring event.
Everything working fine.
I need one thing.That is, i want to catch popup message.
How do i do that.
1) enter value into cell
2) Delete value from cell
3) move to other cell
How do i catch that msg..?
anna
AD
Administrator
Syncfusion Team
August 25, 2005 01:38 PM UTC
If you do not want to see the message, you can handle the ValidateFailed event, and there set grid.CurrentCell.ErrorMessage = "". (Or, if you are setting the message in your validating handler, you can set grid.CurrentCell.ErrorMessage = "" there.)
AS
Anna Srinivasan
August 25, 2005 02:34 PM UTC
Hi,
How to set value back to null..?
I dont want any err msg if cell is blank.
Thanks, Anna
AD
Administrator
Syncfusion Team
August 25, 2005 03:35 PM UTC
If you set it to the empty string, it should not display.
AS
Anna Srinivasan
August 26, 2005 03:50 AM UTC
If i set empty msg , i am not getting msg box.
But i am not able to move to other cell.
I want to move to other cell, if cell is empty.
AD
Administrator
Syncfusion Team
August 26, 2005 06:25 AM UTC
>>I want to move to other cell, if cell is empty.
If you want to move to another cell, then you should not set e.Cancel = true. If you are not setting e.Cancel = true and you are using 3.x code, then check whether your DataColumn accepts nulls.
If you can upload a sample showing the problem you are having, then maybe we can suggest a solution.
AS
Anna Srinivasan
August 26, 2005 09:18 AM UTC
Hi,
My database columns accepts null values.
I am using this code in currentcellvalidatingstring event.
I have comment out e.cancel line also.
But still i am not move to other cell, if field is empty.
What is 3.x code..?I dint understand.
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
string newValue = e.Text;
if(cc.ColIndex >= 2 && cc.ColIndex <= 6) {
double d;
if (newValue.Trim() != "") {
if(!double.TryParse(newValue, System.Globalization.NumberStyles.Any, null, out d)) {
//e.Cancel = true;
cc.ErrorMessage = string.Format("Invalid double value");
}
}
}
AS
Anna Srinivasan
August 26, 2005 09:23 AM UTC
I am using this event to prevent err msgbox.
But i am not getting any err msg box. but i am able to move other cell.
private void sgbDetailedHistory_ValidateFailed(object sender, Syncfusion.Windows.Forms.Grid.GridValidateFailedEventArgs e) {
this.sgbDetailedHistory.CurrentCell.ErrorMessage = "";
}
AD
Administrator
Syncfusion Team
August 26, 2005 11:54 AM UTC
3.x code is some 3.x.x.x version of our libraries.
I am confused about what you want. You should step through your code (all the events you are handling) in the situation where you are not getting the behavior you want, and try to spot what is going wrong. If you can attach a sample, and decribe the behavior you want, we can try to do this work here.