Re: No Tab Stop DataGridView Column




"Richard MSL" <RichardKirkness@xxxxxxxxxxxxx> wrote in message
news:D8581263-FF62-40BD-898A-F9F1248A7B00@xxxxxxxxxxxxxxxx
I have a DataGridView control with some regular columns, and some columns
that are just for display, populated by my program. The user is not
supposed
to be able to change the data in these columns, or even tab or mouse to
them.
I can set the column ReadOnly property, but the tab and mouse still allow
that column to be selected.

Is there a way to make the column just display, without being able to tab
or
mouse to it? When the user tabbed from the column on the left, I want it
to
just skip over the display column, directly to the next editable column.
Thanks.

You would think that such a common requirement would be natively available
but it's not. You have to roll it yourself and it's not trivial. For one
thing, the grid is buggy and will often result in various errors if you try
to change the target cell from within different "DataGridView" event
handlers (when you trying to modifyc the "CurrentCell" property typically).
The following is the most common:

"Operation is not valid because it results in a reentrant call to the
SetCurrentCellAddressCore function"

I saw at least one posting elsewhere where Mark Rideout confirms this
problem under some another circumstance. He's the guy who manages this
control at MSFT. The only way I've been able to find to circumvent this
problem (after much pain) was to provide a "DataGridView" derivative. You
then have to override "SetCurrentCellAddressCore()" and
"SetSelectedCellCore()" and change the "columnIndex" parameter (and/or
"rowIndex") before invoking the base class version. You may also have to
implement an "OnKeyDown()" override as well. For instance, in my case, the
left-hand column is always off-limits to the user. If they click it then the
first two functions mentioned above will automatically move them to the
adjacent cell on the right. If they then <Shift-Tab> from the latter column
however then my "OnKeyDown()" override traps it and sets "CurrentCell" to
the right-most column on the previous visible row (assuming they're not on
the first visible row in the grid at the time - make sure you're handling
*visible* rows when you do this, assuming your grid contains hidden rows
either now or in the future). You'll have to experiment to get everything
right of course and cope with the frustration along the way. Good luck.


.



Relevant Pages

  • Re: Tabs Missing / Monitor Display Problems =(
    ... The Settings tab? ... ScreenSaver Disable/Enable or Tab Missing ... Restore the Web Tab - Display Properties ... Windows XP Style Changes to Windows Classic ...
    (microsoft.public.windowsxp.general)
  • Re: Imminent alpha release of Portal Builder for Delphi
    ... what browser are you using? ... >>>display inside the IFRAME. ... on "fabrics" page, after selecting any fabric tab, the selected ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Background
    ... Assuming that the machine is clean, go to the Display applet in Control ... Panel and look on the Desktop tab. ... If you can't enable desktop backgrounds after a virus, ...
    (microsoft.public.windowsxp.general)
  • Re: need help,,,,
    ... Subforms are used primarily to display the many side of a one-to-many ... relationship, such as Customers and Orders, but are also useful in dividing a ... efficiently--you can put each task or series of tasks on a single tab. ...
    (microsoft.public.access.forms)
  • Re: Background Issue
    ... went through the msconfig disabling everything; still no luck. ... Wallpaper background reverts to Blue color. ... When I go into "Display Properties/Desktop Tab" the ability to ... I've tried "Settings" tab, whatnot, to no avail. ...
    (microsoft.public.windowsxp.general)