TextBox default context menu

J

jonpb

When the ContextMenuStrip property of a TextBox is set to null the
system default context menu is used. To stop this from happening you
must set the ContextMenuStrip property to, at least, a dummy one with no
items.

Due to the proliferation of TextBoxes in a normal application, i.e. they
are used DataGridCells, NumericUpDownBoxes, etc, etc. I was wondering if
there is an Assembly level attribute or config property to not use the
system TextBox context menu when the ContextMenuStrip property is null?

Or better yet, replace the system one with a custom one which will be
used when ever the ContextMenuStrip property is null.

Thanks
 
J

Jeff Johnson

When the ContextMenuStrip property of a TextBox is set to null the system
default context menu is used. To stop this from happening you must set the
ContextMenuStrip property to, at least, a dummy one with no items.

Due to the proliferation of TextBoxes in a normal application, i.e. they
are used DataGridCells, NumericUpDownBoxes, etc, etc. I was wondering if
there is an Assembly level attribute or config property to not use the
system TextBox context menu when the ContextMenuStrip property is null?

Or better yet, replace the system one with a custom one which will be used
when ever the ContextMenuStrip property is null.

So I have to ask: it is your goal to deny your users the ability to Cut &
Paste?
 
J

jonpb

Jeff said:
So I have to ask: it is your goal to deny your users the ability to Cut &
Paste?

Of course not, but I would like to have control of it. It is
particularly a problem with textboxes embedded in other controls like
grid cells. That system context menu is not working well with my custom
grid context menu. That is just one scenario, there are others where
this system context menu just gets in the way.
 
M

M.H.

Jeff said:
So I have to ask: it is your goal to deny your users the ability to
Cut & Paste?

Do you think your question will help to solve his problem?

MH
 
J

Jeff Johnson

Do you think your question will help to solve his problem?

Possibly. Very often posters have tunnel vision on their particular
situation and think they need to do one particular thing to solve it. By
trying to determine what their ultimate goal is, we can often suggest
alternatives.
 
J

Jeff Johnson

Of course not, but I would like to have control of it. It is particularly
a problem with textboxes embedded in other controls like grid cells. That
system context menu is not working well with my custom grid context menu.
That is just one scenario, there are others where this system context menu
just gets in the way.

What kind of "control" are you looking for? You could derive from various
controls (like NumericUpDown), override the WndProc method, and trap
messages like WM_COPY, WM_PASTE, etc., and handle those actions as you wish.
Then you'd place instances of your derived class on the form instead of the
regular control. I'm not sure this would help with your grid (unless you're
manually simulating in-cell editing by floating a text box over the grid, in
which case you could derive from the TextBox class as well).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top