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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ValidateValues

Thread ID:

Created:

Updated:

Platform:

Replies:

1899 Dec 3,2002 11:18 PM UTC Mar 22,2004 09:57 PM UTC WinForms 16
loading
Tags: GridControl
Tom Le Blanc
Asked On December 3, 2002 11:18 PM UTC

I had posted a question about the ValidateValueInfo class and its members, specifically NumberRequired on another posting, but it never got answered and it appears to have disappeared. Your built-in NumberRequired method is fine until the user wants to remove their entry completely (and not just change it to 0). Do you have any examples of working around that limitation of the NumberRequired method or rolling a similar routine with the ValidateValueInfo class? Thanks, Tom

Administrator [Syncfusion]
Replied On December 4, 2002 11:53 AM UTC

Tom, The NumberRequired should be set to false if you want the user to be able to enter blanks. When this is set to true, your user must enter a non-blank number. Attached is a little sample showing this for both a GridControl and a GridDataBoundGrid. Each has a number cell (or column) that can be blank and one that cannot be blank. Notice, that the style's CellValueType is explicitly set so the cell knows what to expect. Just a mention regarding the primary purpose of this forum. The Grid forum is primarily intended for community interaction. While Syncfusion employees will post here on a time permitting basis, you cannot rely on it. If there is a problem/question that you want a timely response to, then you should post it through our Direct-Trac support system. This system is an on-demand support system where an engineer is notified of your question as some as you post it. In Direct-Trac, you will get quicker responses, and no question should be left unanswered. You will also have a log of your questions and answers in one place for future reference, and Syncfusion will have a database of questions and answers that will allow us to serve you better in the future.

Tom Le Blanc
Replied On December 4, 2002 01:53 PM UTC

Clay, I know about Direct-Trac but I didn't think my question needed to go to that level and I _am_ hoping for interaction from the community on answering my question. My concern was that the thread on which I originally posted my question vanished. I already know about setting NumberRequired to true or false (your attached sample wasn't), what I'm asking is about the use of the ValidateValueInfo class. The thread on which I originally posted my question showed us how to use it, but it basically just show another way of creating NumberRequired. I'm looking for some help on using the class and its members to roll a validation that requires numbers, but will also take a blank space. Or, should I just undo or escape the user's entry if they are trying to make the cell blank? Thanks, Tom

Administrator [Syncfusion]
Replied On December 4, 2002 02:38 PM UTC

> Clay, > > I know about Direct-Trac but I didn't think my question needed to go to that level and I _am_ hoping for interaction from the community on answering my question. My concern was that the thread on which I originally posted my question vanished. > > I already know about setting NumberRequired to true or false (your attached sample wasn't), what I'm asking is about the use of the ValidateValueInfo class. The thread on which I originally posted my question showed us how to use it, but it basically just show another way of creating NumberRequired. I'm looking for some help on using the class and its members to roll a validation that requires numbers, but will also take a blank space. > > Or, should I just undo or escape the user's entry if they are trying to make the cell blank? > > Thanks, > Tom Tom, Sorry about not adding the sample. here it is. Did you look in the Archives for your original post? There is a link to the Archives on the first forum page. Postings made before October 1, 2002, can be found there. I guess I am confused about what you are asking. I thought if you set numberrequired to false, you would get exactly the behavior you want, ie. the cell could accept either numbers or an empty string. The attached sample has this behavior, and all it does is set NumberRequired to false. How does this behavior differ from what you want? Regards, Clay

Tom Le Blanc
Replied On December 4, 2002 10:03 PM UTC

Thanks Clay, The sample helped. I had been frustrated by the ValidateValues.NumberRequired Boolean. That one basically just turns the validation on or off. While the NumberRequired member of ValidateValueInfo as used in the constructor and your sample: ... New GridCellValidateValueInfo(False, 0, 1000, "Enter between 0 and 100") does exactly what I need and as you advertised. Sorry for any confusion in my not indicating the ValidateValues vs ValidateValueInfo more clearly. Regards, Tom

Philip Bishop
Replied On February 9, 2004 01:09 PM UTC

i have a question about validating. i searched the forums and found this sample and wondered if you could help me take it a step further. What happens if a user was in this sample app and then went to excel and copied a range of cells. for example. go to excel or another grid and in column one and two and row one and two put in 99999 in each cell. so thats four cells with the value 9999 in each one. then try and copy and paste the four cells into this sample app in its colum 1 and 2 and row 1 and 2 by selecting it as a range. when u do and then click off the fields it doesnt give u the validate error about the fields are not between 0 and 100 that it does when u enter the 99999 in a single cell. How can i catch that??? What i would really like it do is if the user enters what i said above and pasted them in, i''d like it instead of and error message for 4 cells(which it isnt doing at all now), i''d like it to come up with one error message and set all the cells they copied to in a range to the max validate value. I will attach the sample again that i downloaded in case it doesnt attach it here or u dont have it >> Clay, >> >> I know about Direct-Trac but I didn''t think my question needed to go to that level and I _am_ hoping for interaction from the community on answering my question. My concern was that the thread on which I originally posted my question vanished. >> >> I already know about setting NumberRequired to true or false (your attached sample wasn''t), what I''m asking is about the use of the ValidateValueInfo class. The thread on which I originally posted my question showed us how to use it, but it basically just show another way of creating NumberRequired. I''m looking for some help on using the class and its members to roll a validation that requires numbers, but will also take a blank space. >> >> Or, should I just undo or escape the user''s entry if they are trying to make the cell blank? >> >> Thanks, >> Tom > >Tom, > >Sorry about not adding the sample. here it is. > >Did you look in the Archives for your original post? There is a link to the Archives on the first forum page. Postings made before October 1, 2002, can be found there. > >I guess I am confused about what you are asking. I thought if you set numberrequired to false, you would get exactly the behavior you want, ie. the cell could accept either numbers or an empty string. The attached sample has this behavior, and all it does is set NumberRequired to false. > >How does this behavior differ from what you want? > >Regards, > >Clay > > ValidateInfo_1941_8847.zip

Administrator [Syncfusion]
Replied On February 9, 2004 06:59 PM UTC

You will have to use the PasteCellText event to validating text being pasted. For this event to be hit, you must make sure you are only pasting text and not styles. (This is teh default behavior for GridDataBoundGrid). Here are some snippets. ''subscribe to the event AddHandler Me.GridDataBoundGrid1.Model.PasteCellText, AddressOf gridModel_PasteCellText ''a sample handler Private Sub gridModel_PasteCellText(ByVal sender As Object, ByVal e As GridPasteCellTextEventArgs) If e.ColIndex = 1 Or e.ColIndex = 2 Then Try Dim i As Integer = Integer.Parse(e.Text) If i > 100 Or i < 0 Then Throw New Exception("") End If Catch MessageBox.Show("Cannot paste this improper value") ''e.Abort = True e.Cancel = True End Try End If End Sub

Philip Bishop
Replied On February 10, 2004 11:35 AM UTC

Ok so i think i left something out in my question. I am using currency cells in my app and the pastecelltext doesnt seem to work there. I can make it fire the pastecelltext event fine when its a text cell but when its a currency cell it does nothing. is that what u meant when u talked about styles??? How do i go about catching this when its a currency cell or can i??

Administrator [Syncfusion]
Replied On February 10, 2004 12:48 PM UTC

If you are copying and pasteing text, then PasteCellText should be hit. So, if you copy values from excel, then try to paste them into the grid (in your currency cells), your pastecelltext should be hit as this is a text operation. But if you copy and paste from 1 grid to another, the default pasting will copy the style information (not just the text). In this case, your PasteCellText will not be hit. You can turn off pasting of style information using this property. Me.GridDataBoundGrid1.Model.Options.DataObjectConsumerOptions = GridDataObjectConsumerOptions.Text

Philip Bishop
Replied On February 10, 2004 01:03 PM UTC

Clay, I was pasting from excel. I just tried pasting one cell from excel with five 9''s in it to a field in that previous sample that i had changed to a currency cell. The pastecelltext does not get fired. If i do the same paste to a text cell it works fine??? So i already did that

Administrator [Syncfusion]
Replied On February 10, 2004 02:14 PM UTC

The behavior I see in 2.0.2.1 is that if the currency cell is actively being edited when you paste and you are pasteing exactly 1 cell, then PasteCelltext does not get hit, but the standard validation you you try to leave the cell catches the error. But if the currency cell is not actively being edited and you are pasteing 1 cell, or if you are pasteing more than one cell, the PasteCellText is hit. The PasteCellText is not fired for pasteing into a single active cell, but the standard validation of this pasted text should take place when you try to leave this cell. Are you using a different version and not seeing this behavior. Here are two picture showing the the messages that are triggered for each paste. test_4102.zip

Philip Bishop
Replied On February 10, 2004 02:28 PM UTC

Clay, Again I think there is some confusion on my part. I am using the non data bound grid. I am using in that sample gridcontrol1 not the GridDataBoundGrid1 that comes up on the left of the form that u were using. Does that change anything. We are still using 2.0.2.0. Let me know

Administrator [Syncfusion]
Replied On February 10, 2004 03:04 PM UTC

I see teh same behavior in the gridcontrol. If teh currencycell is active, I see the (default)error message when I try to leave it. If the currencycell is not active, I see the message in PasteCelltext. Here is the sample I was working with. forum1899_2892.zip

Philip Bishop
Replied On February 10, 2004 04:40 PM UTC

Ok i think i see whats going on. I didnt get the whole EDIT mode part. If im in edit mode it gives me the error message and if its not it goes to the pastecelltext event. This is what I am confused on and i think it relates to a direct trac incident that my co worker has open with you#7677. How come when I click 3 cells that are currency cells and paste them in to 3 cells that are either currency or text cells the copy and paste doesnt work. It only copies the cell that was in EDIT mode. Easy example is this. Swipe 3 cells that are text cell and notice how no cells u''ve swiped are active or in edit mode. If u do the same thing and swipe the 3 CURRENCY cells this time u will notice that the first one u click becomes active or in edit mode. This is where it relates to direct trac #7677. Copy and pasting with currency cells doesnt seem to work. I want when i click 3 currency cells for it not to go into edit mode in my case and then it would always go to the pastecelltext event. Then we also think the copy and paste of currency cells would work also. Jay told my coworker that this had been fixed in version 2.0 beta which wasnt the case. Our last contact about this was on 1/19 with jay and he was notifying the development team. So the copy and paste is an issue that i think will also change how this pastecelltext event works when a cell isnt in edit mode. So to recap yeah I am seeing what your seeing but from what we''ve been told it shouldnt be in edit mode like that on a currency cell. Jay sent a sample workaround the last time we spoke to him that didnt work. I just want to have someone paste whatever range and if its over my max validate cell value have it put in the max i allow and move on to the next cell in the selected range until all done with the range and put up a generice message about one or more cells may of been defaulted in that paste and i think i can do that once this copy and paste or currency cell in edit mode issue is solved. Ok let me know if that makes any sense or u have any suggestions.

Administrator [Syncfusion]
Replied On February 10, 2004 06:10 PM UTC

The paste problem with the leading currency cell has been corrected in our code base here. When I run that sample, I can select 3 currency cells, and paste into those cells from excel, either getting error messages or not depending upon what is pasted. This correction will be in the next release. (I do not know when that will be, but suspect it will be in the next week or so.)

Philip Bishop
Replied On March 22, 2004 06:48 PM UTC

Ok so i''m testing this new version of your grid with the samples u sent me and it seems to work now but i''m kinda stumped on something. Is there a way in the pastecelltext or another event to be able to stop after the first error. If ur pasting 10 fields of says five 9''s into ur grid where the each cell can only hold 3 9''s is there a way to once the first try catch happens to stop the pastecelltext from happening anymore if a range was being copied. the way the sample works now is it gives the error messages 10 times. I''d just like one error message and then be one and allow no more pasting. Like if u could check the clipboard before or something. Thats where I am stumped. Can this be done? Phil

Administrator [Syncfusion]
Replied On March 22, 2004 09:57 PM UTC

In PasteCellText, if you set e.Cancel = True then the value is not pasted. If you also set e.Abort = True, no further pastes should be attempted.

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

;