Question How to use hasfocus with cell in DGV

Nader

Well-known member
Joined
Oct 9, 2008
Messages
55
Programming Experience
Beginner
I am using vb.net
How to use hasfocus with cell in DGV.
It mean excuted the code when there is
mouse curso in the cell
 
You wouldn't use "hasfocus" because there is no such thing. Please provide a FULL and CLEAR explanation of what you're trying to achieve. Descriptions that are vague or downright wrong don't help us help you.
 
Excuted the code when the mouse cours in the cell of DGV.
If mouse cours in the cell of DGV then excute the code
 
The mouse cursor has nothing to do with focus. I emphasised "FULL" and "CLEAR" for a reason. Do you want to do something when the mouse pointer enters a cell or when a cell receives focus?

That said, either way, you're going to be handling an event and putting code in the event handler. You should be able to look at the events available for the DataGridView control for yourself and pick the right one to handle. Any events related to specific cells have names that begin with "Cell", so they're easy to identify.
 
I used cell.selected intead of the last way.
That's a property, not an event, and it has nothing at all to do with focus or the mouse pointer, so a bad idea all around.
 
I got the solution for my project by using selected.
I have my doubts whether that's actually true, unless you you described your requirements even more poorly than I thought. It may appear to do what you need but I suspect that, at the very least, there is a better way. It's up to you whether you want to find out whether or not that's the case.
 
Back
Top