|
-
Apr 18th, 2005, 12:48 PM
#1
Thread Starter
New Member
Validation problem [RESOLVED]
Hello everyone,
I need a way to avoid that a clicked control gets the control, is there a way to do it ?
This is my case, I have a text box that the only valid values are the ones that exists in a data combo, but I need to give the control to the data combo when the value in the text box is incorrect and retain the control until the user select a correct value.
Right now I can do it when I manually run the textbox1_validate event (in the keyup event), but when the user uses tab key or mouse to move to another control, I can not trap the control in the data combo.
I am using the cancel variable in the validate event, but does not work because then I can not go to the data combo,
Thanks
Last edited by rodrvars; Apr 19th, 2005 at 01:57 PM.
Reason: RESOLVED
-
Apr 18th, 2005, 01:07 PM
#2
Re: Validation problem
There is also the Lost_Focus property that you can use.
-
Apr 18th, 2005, 01:22 PM
#3
Frenzied Member
Re: Validation problem
 Originally Posted by rodrvars
Hello everyone,
I need a way to avoid that a clicked control gets the control, is there a way to do it ?
This is my case, I have a text box that the only valid values are the ones that exists in a data combo, but I need to give the control to the data combo when the value in the text box is incorrect and retain the control until the user select a correct value.
Right now I can do it when I manually run the textbox1_validate event (in the keyup event), but when the user uses tab key or mouse to move to another control, I can not trap the control in the data combo.
I am using the cancel variable in the validate event, but does not work because then I can not go to the data combo,
Thanks
Just a thought... don't u have a textbox with a datacombo? why do u need to add a separate textbox?
and you can also code in Text1_Validate Event.. just don't use cancel... rather.. you can use If Text1 is not valid then dbcombo1.SetFocus... and on datacombos validate event you can set cancel = true if the textbox is still not valid..
-
Apr 18th, 2005, 02:54 PM
#4
Thread Starter
New Member
Re: Validation problem
Thanks Dglienna and Moinkan.
Dglienna, I am gonna try to use the lostfocus event, but I don't know if over there I can use setfocus.
Moinkan, I am using the text and the data grid (exucuses, not datacombo) to simulate a multicolumn combobox, and Rigth now I am doing the same thing that you told me but, when the user click on other control the datagrid doesn't keep the control.
Thanks again
-
Apr 18th, 2005, 02:57 PM
#5
-
Apr 18th, 2005, 03:12 PM
#6
Thread Starter
New Member
Re: Validation problem
Dglienna,
When I try to give the focus on the lostfocus event I got an error :
Run-time error '5':
Invalid procedure call or argument
This is the event code :
Private Sub MyFlexGrid_LostFocus()
If Not m_Status_Val Then
MyFlexGrid.SetFocus
End If
end sub
The m_status_val is the boolean var that says if the value is valid or not
Thanks
-
Apr 18th, 2005, 03:18 PM
#7
Re: Validation problem
You have to supply the cell to focus on.
VB Code:
MyFlexGrid.textmatrix(r,c).SetFocus
-
Apr 18th, 2005, 03:22 PM
#8
Re: Validation problem
DG - I've never seen setting the focus to a particular cell - do you really use that?
-
Apr 18th, 2005, 03:32 PM
#9
Thread Starter
New Member
Re: Validation problem
Dglienna,
I am using DataGrid, so that TextMatrix property does not exists
-
Apr 18th, 2005, 03:36 PM
#10
Re: Validation problem
 Originally Posted by szlamany
DG - I've never seen setting the focus to a particular cell - do you really use that?
hmmm. it looked right at the time, but I was thinking of the floating textbox rather than the cell. sorry about that.
Not sure about the datagrid. I don't think you can specify individual cells. that's why I assumed that it was a flexgrid.
-
Apr 18th, 2005, 05:02 PM
#11
Re: Validation problem
Just a crazy thought, but why don't you use SetCapture when you want to lock out all other controls and ReleaseCapture when you don't?
VB Code:
Option Explicit
Private Declare Function SetCapture Lib "user32" ( _
ByVal hwnd As Long _
) As Long
Private Declare Function ReleaseCapture Lib "user32" ( _
) As Long
To set capture to your datagrid just call
VB Code:
SetCapture DataGrid1.hwnd
and to release it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|