PC Review


Reply
Thread Tools Rate Thread

Preventing focus from leaving DataGridView

 
 
Larry
Guest
Posts: n/a
 
      25th Dec 2007
Hi,

I need to prevent a user from moving away from a DataGridView if it contains
invalid data.

Some specifics: The user should be able to move within the specific grid,
but not move to any other control on the form (including any other grid on
the form). I have tried a number of methods, for example:
1) From the Leave event of the grid: Set focus back to the grid (with and
without also calling BeginEdit)
2) From the RowValidating, set cancel = true if invalid data
3) From CellValidating, set cancel = true if invalid data

None of the above prevents the user from leaving the grid.

I could get it to work by trapping the Enter event on all other controls on
the form and setting focus back to the grid in question as needed from
there, but there must be a better way than that.

Does anyone know of a cleaner method to accomplish this?

Thanks,
Larry




 
Reply With Quote
 
 
 
 
Larry
Guest
Posts: n/a
 
      27th Dec 2007

Anyone??



 
Reply With Quote
 
Colin Han
Guest
Posts: n/a
 
      27th Dec 2007
Hi, Larry,
My English is poor. I just write solution for my understanding. If you has
more question. Can discuss with me continus.

If you want control can not leave focus, you should handle Validating
event to set e.Cancel to true.
So, user can move current cell in this dataGridView. but he can not set
the focus to other controls. And the application will cannot to close.

"Larry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Anyone??
>
>
>


 
Reply With Quote
 
Jeff Gaines
Guest
Posts: n/a
 
      27th Dec 2007
On 27/12/2007 in message <(E-Mail Removed)> Larry wrote:

>
>Anyone??


What about capturing the Validating event and restoring focus if the data
is not valid?

--
Jeff Gaines
 
Reply With Quote
 
Larry
Guest
Posts: n/a
 
      27th Dec 2007

> What about capturing the Validating event and restoring focus if the data
> is not valid?


Tried that - does not work (but you'd think it would - not sure why it does
not). Seems like an oversight in the design of the grid that this should be
so hard...

Larry


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing Users from Leaving the Main Switchboard =?Utf-8?B?Uml0YQ==?= Microsoft Access Database Table Design 10 22nd Mar 2007 09:21 PM
VB2005 - Stop User from Leaving Row in DataGridView Matt Microsoft VB .NET 8 17th Jan 2006 08:46 AM
DATAGRID and MouseWheel - focus keeps leaving the grid =?Utf-8?B?RGFycmVsbCBXZXNsZXk=?= Microsoft VB .NET 0 4th Apr 2005 11:01 PM
Focus not leaving after BeforeUpdate runs davidwv Microsoft Access 1 22nd Jan 2004 03:11 PM
Control Tabs - Preventing user from leaving page Patrick GRaham Microsoft Access Form Coding 1 14th Oct 2003 01:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:48 PM.