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

Reg; GridDatabound Control error msg

Thread ID:

Created:

Updated:

Platform:

Replies:

33733 Aug 25,2005 02:01 AM Aug 26,2005 07:54 AM Windows Forms 10
loading
Tags: GridControl
Anna Srinivasan
Asked On August 25, 2005 02:01 AM

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

Administrator [Syncfusion]
Replied On August 25, 2005 03:11 AM

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.

Anna Srinivasan
Replied On August 25, 2005 07:41 AM

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

Administrator [Syncfusion]
Replied On August 25, 2005 09:38 AM

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.)

Anna Srinivasan
Replied On August 25, 2005 10:34 AM

Hi, How to set value back to null..? I dont want any err msg if cell is blank. Thanks, Anna

Administrator [Syncfusion]
Replied On August 25, 2005 11:35 AM

If you set it to the empty string, it should not display.

Anna Srinivasan
Replied On August 25, 2005 11:50 PM

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.

Administrator [Syncfusion]
Replied On August 26, 2005 02:25 AM

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

Anna Srinivasan
Replied On August 26, 2005 05:18 AM

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"); } } }

Anna Srinivasan
Replied On August 26, 2005 05:23 AM

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 = ""; }

Administrator [Syncfusion]
Replied On August 26, 2005 07:54 AM

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.

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

;