AD
Administrator
Syncfusion Team
May 3, 2006 07:20 AM UTC
Hi Phil,
You need to handle the CurrentCellKeyDown event to store the Old cellvalue in a current cell and assign this value to current cell of the grid
in Grid''s CurrentCellValidating event.Here is a code snippet.
Private Sub gc1_CurrentCellValidating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles gc1.CurrentCellValidating
Dim i As Single
If Me.gc1.CurrentCell.RowIndex > 0 AndAlso Me.gc1.CurrentCell.ColIndex > 0 Then
i = CSng(Me.gc1.CurrentCell.Renderer.ControlText)
Select Case i
Case 0, 501.0F To 532.0F
Case Else
MessageBox.Show("Cell value must be between 501 and 532." & ControlChars.CrLf & _
"The invalid value will be reset.", _
"QUASAR: Invalid Value Entered", MessageBoxButtons.OK, _
MessageBoxIcon.Warning)
If Not cellText = String.Empty Then
Me.gc1(Me.gc1.CurrentCell.RowIndex, Me.gc1.CurrentCell.ColIndex).Text = cellText
End If
gc1.CurrentCell.CancelEdit()
gc1.CurrentCell.Refresh()
e.Cancel = True
End Select
End If
cellText = String.Empty
End Sub
Dim cellText As String = String.Empty
Private Sub gc1_CurrentCellKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles gc1.CurrentCellKeyDown
If e.KeyData = Keys.Delete Then
cellText = Me.gc1(Me.gc1.CurrentCell.RowIndex, Me.gc1.CurrentCell.ColIndex).Text
End If
End Sub
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/acceptchangestest_19aac91b.zip
Please let me know if this helps.
Thanks for your interest in Syncfusion Products.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
May 3, 2006 02:12 PM UTC
So how come this is only an issue when I have the controladded event? If I comment it out it works fine?
AD
Administrator
Syncfusion Team
May 3, 2006 02:31 PM UTC
Ok a few other things I have question about including my last question. How come it only is a problem when the control added event is in the code? Next your code doesnt work in all situations. For example if they click a header col cell like 0,1 and hit delete well then it puts the text I have in that header cell in to your celltext and then it blows up. I got around that by checking in keydown and verifying that it wasnt col or row 0. Is this the only way around this using keydown and again how come it only seems to be an issue when control added is in your code?
AD
Administrator
Syncfusion Team
May 3, 2006 02:48 PM UTC
Is there another way to go about this? I''m finding I am going to have to keep track of this celltext all over the place now. I really would like to know why it doesnt work with control added and go from there.
AD
Administrator
Syncfusion Team
May 4, 2006 05:14 AM UTC
Hi Philip,
Sorry for the inconvenience caused.
We are looking into this issue and get back to you very soon.
Thanks for your patience.
Regards,
Haneef
AD
Administrator
Syncfusion Team
May 8, 2006 02:29 PM UTC
Any news on this???
AD
Administrator
Syncfusion Team
May 8, 2006 02:48 PM UTC
Phil,
I did some tracing to find out what is the difference between those two code samples (with or without context menu).
When you assign a context menu I noticed that a ProcessDialogKey message is being sent. If you do not have a context menu then it is not.
You can add this override then you see the difference:
Protected Overrides Function ProcessDialogKey(ByVal Key As Keys) As Boolean
If Key = Keys.Delete Then
Return True
End If
Return False
End Function
It looks as the context menu raises that method call. With the grid that means now that the Delete key is first sent to the grid instead of being sent first to the currency textbox.
The grid then thinks the delete was not handled by the currency cell and acutally calls ClearCells. At that moment "0" is saved and commited to the style object.
The following code makes it work when the ContextMenu was added. It ensure that the grids call to ClearCells does not have any effect in that case:
Dim ignoreNextClear As Boolean = False
Protected Overrides Function ProcessDialogKey(ByVal Key As Keys) As Boolean
If Key = Keys.Delete And Me.gc1.CurrentCell.HasControlFocus Then
ignoreNextClear = True
End If
Return False
End Function
Private Sub gc1_ClearingCells(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridClearingCellsEventArgs) Handles gc1.ClearingCells
If ignoreNextClear Then
e.Handled = True
e.Result = False
End If
ignoreNextClear = False
End Sub
Stefan
>Hi Philip,
>
>Sorry for the inconvenience caused.
>
>We are looking into this issue and get back to you very soon.
>
>Thanks for your patience.
>
>Regards,
>Haneef
AD
Administrator
Syncfusion Team
May 8, 2006 03:23 PM UTC
Hey thanks for the quick reply. Before I go putting that code in the forms that need it, is there any other way I can get rid of the context menu on the forms that are affected that might in turn not cause it to act this way? Any other wide I can make it not work because doing the controladded?
AD
Administrator
Syncfusion Team
May 10, 2006 03:38 PM UTC
Any thoughts on my last post????
AD
Administrator
Syncfusion Team
May 12, 2006 07:10 PM UTC
Phil,
sorry for the late reply but I revisited the topic multiple times and debugged into it and wasn''t sure if I should actually put the workaround into our codebase.
I finally decided to do so. In upcoming builds the Currency TextBox will check if a ProcessDialogKey for the Delete key is raised while the cell is active and in such case tell the grid not to Clear the cells.
I also recompiled the custom grid dll (v 4.1.0.601) I sent you earlier and with that code included. Please check if this fixes your problem.
The assembly is here (1.1 and 2.0 framework)
ftp://syncpatch.syncfusion.com/EssentialStudio/PrivateBuilds/Syncfusion_Grid_Windows_401_601_phil.zip
Stefan
AD
Administrator
Syncfusion Team
May 15, 2006 01:40 PM UTC
Ok I downloaded and installed or tried to install. Since It didnt include the 1.0 framwork which we dont use I deleted that out of the precopiled assemblies folder and copied in your 2 new dll''s in to its proper folder. Then after starting the assembly manager I noticed I couldnt read any of the text on the assembly manager screen where it says install or remove or remove all. It was all srunched down on mulitple lines. So I put back on the original version you sent me that had the 1.0 version and then again copied over the 1.1 and 2.0 fix you just sent. Now I could see everything fine in assembly manager. I did the remove all and then installed. So then I went in a currency cell. Got it in active edit mode. The value was 203 and a valid value is 201 to 232. I highlighted in active edit mode just the 03 and hit delete. Then when I moved off the cell it gave me my error message saying invalid but it still changed the cell to 0 instead of putting 203 back in it. So I guess I want to make sure I didnt do anything wrong in copying these over because if I didnt, it still appears not to of fixed what you wanted to fix. Any ideas?
AD
Administrator
Syncfusion Team
May 15, 2006 01:57 PM UTC
One other thing I noticed that may or may not help. I noticed the size of the first dll you sent and the one you just made are the same size. Dont know if that helps at all but I was trying to make sure I did everything right on my end. Thanks.
AD
Administrator
Syncfusion Team
May 17, 2006 12:56 PM UTC
Just wondered if you figured anything out on this?
AD
Administrator
Syncfusion Team
May 19, 2006 07:03 PM UTC
Just making sure this didnt get lost in the 1000''s of questions you get.
AD
Administrator
Syncfusion Team
May 21, 2006 02:35 PM UTC
Hi Phil,
can you try with the 4.2 RC?
The RC has been updated on the site. It can be downloaded from - http://www.syncfusion.com/Downloads/latestversion.aspx.
You will have to obtain a new key from Direct-Trac (this should be up later tonight) or by sending an email to sales.
I was waiting for this RC to be out before replying ...
The RC also supports the RangeStyles serialization we discussed in another forum thread. Please let us know if you see any problems.
Best regards,
Stefan
AD
Administrator
Syncfusion Team
May 22, 2006 02:30 PM UTC
Stefan,
Hey that worked for me perfectly. I do have a couple of questions left. First this 4.2RC version is something I can release to clients? I really dont want to have to download another version when the final comes out and have to re-test everything all over again. Secondly when I first ran it on my project it wanted to do a fix it, but it appears it didnt do anything and it ran fine. Just wondered what that was about. Lastly when we first tested it, it was still putting in a zero. For example when 301 was valid and i would delete the 01 from 301 it would put a 0 in after my error message instead of putting back the 301. So I then commented out the clearing cells section and it worked fine. Is that how its suppose to work? We dont really need the clearning cells and the only reason we have it is because you guys told us to put it in back when nullstring wasnt working how it works today and since version 3. Early on you had us NOT use nullstring and then you changed how it all worked in version 3. Instead of using null string you had us put in the clearingcells event. Once 3 came out then when we would hit delete on a cell it would leave it blank on currency cells because we werent using nullstring. In versions before 3 it would put a zero and you changed that all in 3 and beyond so I am guessing we dont need the clearingcells at all anymore. Anyway I just thought I would let you know that it doesnt work with the clearning cells but does without it. Can you let me know? Thanks
Phil
AD
Administrator
Syncfusion Team
May 22, 2006 06:23 PM UTC
Hi Phil,
the 4.2 release itself should be out really soon and I would suggest you uninstall/reinstall the final version. There are no changes planned in grid anymore but it will be easier for future support if you have the final version.
With the fix I had in mind first for 4.1.0.601 - I am not sure what went wrong and so I thought it is best to try it right away with the 4.2 version.
The "Fix It" / license error dialog will only occur if there is no licx in your project. If it is already there you won''t need to run "Fix It".
There is no need for the workaround any more. The workaround itsself actually would cancel out the changes made in Currency Cell, so don''t use that any further.
One further suggestion: I noticed when you delete the "01" so that "5" remains and you step off the cell by pressing the down arrow and afterwards press F2 or "Pos1/Home" key the "5" will reapear. You can avoid that by calling Initialize as shown in the following code:
Private Sub gc1_CurrentCellValidating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles gc1.CurrentCellValidating
Dim i As Single
If Me.gc1.CurrentCell.RowIndex > 0 AndAlso Me.gc1.CurrentCell.ColIndex > 0 Then
i = CSng(Me.gc1.CurrentCell.Renderer.ControlText)
Select Case i
Case 0, 501.0F To 532.0F
Case Else
MessageBox.Show("Cell value must be between 501 and 532." & ControlChars.CrLf & _
"The invalid value will be reset.", _
"QUASAR: Invalid Value Entered", MessageBoxButtons.OK, _
MessageBoxIcon.Warning)
gc1.CurrentCell.CancelEdit()
gc1.CurrentCell.Renderer.Initialize(gc1.CurrentCell.RowIndex, gc1.CurrentCell.ColIndex)
e.Cancel = True
End Select
End If
End Sub
Stefan
>Stefan,
>
>Hey that worked for me perfectly. I do have a couple of questions left. First this 4.2RC version is something I can release to clients? I really dont want to have to download another version when the final comes out and have to re-test everything all over again. Secondly when I first ran it on my project it wanted to do a fix it, but it appears it didnt do anything and it ran fine. Just wondered what that was about. Lastly when we first tested it, it was still putting in a zero. For example when 301 was valid and i would delete the 01 from 301 it would put a 0 in after my error message instead of putting back the 301. So I then commented out the clearing cells section and it worked fine. Is that how its suppose to work? We dont really need the clearning cells and the only reason we have it is because you guys told us to put it in back when nullstring wasnt working how it works today and since version 3. Early on you had us NOT use nullstring and then you changed how it all worked in version 3. Instead of using null string you had us put in the clearingcells event. Once 3 came out then when we would hit delete on a cell it would leave it blank on currency cells because we werent using nullstring. In versions before 3 it would put a zero and you changed that all in 3 and beyond so I am guessing we dont need the clearingcells at all anymore. Anyway I just thought I would let you know that it doesnt work with the clearning cells but does without it. Can you let me know? Thanks
>Phil
AD
Administrator
Syncfusion Team
May 22, 2006 06:55 PM UTC
Stefan,
Thanks for the advice on waiting for the final version. I hadnt thought about that aspect of needing help that you brought up. They had told us on the phone hopefully by the end of the week or so, so I guess we will just wait.
Thanks for catching the "F2" thing. We knew you could use F2 to get in to edit mode but never tried it in the scenario you did. Is that the ways its suppose to work without adding the initialize? What exactly does the initialize do? I just want to make sure it doesnt affect anything else.
On the license file issue, we did have a license file but it was READ ONLY via source safe. So I dont know if that is what caused it. If there is no change and I already had one, does it need to be writable for the licensing check you do to work?
Thanks
Phil
AD
Administrator
Syncfusion Team
May 24, 2006 03:44 PM UTC
Hi Phil,
no a rebuild all for the project is normally all that should be needed.
If not then cleaning out the obj folder is a good idea to make sure the license resource gets recompiled.
If the licx itsself is readonly that does not matter. It only matters that is included as embedded resource in your project.
Stefan
>Stefan,
>
>Thanks for the advice on waiting for the final version. I hadnt thought about that aspect of needing help that you brought up. They had told us on the phone hopefully by the end of the week or so, so I guess we will just wait.
>
>Thanks for catching the "F2" thing. We knew you could use F2 to get in to edit mode but never tried it in the scenario you did. Is that the ways its suppose to work without adding the initialize? What exactly does the initialize do? I just want to make sure it doesnt affect anything else.
>
>On the license file issue, we did have a license file but it was READ ONLY via source safe. So I dont know if that is what caused it. If there is no change and I already had one, does it need to be writable for the licensing check you do to work?
>
>Thanks
>Phil
>
>