ListView - Get Items Highlighted Text While In Edit Mode

N

NvrBst

ListView is in Detailed Mode, and an Item is in EditMode
(ListViewItem.BeginEdit()), how, if any, would I get the currently
highlighted portion of the text?

Basically I have a ctrl-c shortcut that copies the entire line of the
currently selected items, however, if the user is in Edit Mode I'd
like it just to copy what the user has selected (IE Default Behavior
of Ctrl-C). If I ignore my copy method, "if(InEditMode) return;" then
the default behavior doesn't trigger; I'd need a "if(InEditMode)
{Handled=false; return;}" type thing which doesn't exist I don't
think, so now I'm trying to do "if(InEditMode) Copy Highlighted
Portion of listView1.SelectedItem[0].Text".

Another way would be when entering edit mode to do
"copyMenuItem.ShortCutKeys = Keys.None;" and in the "AfterItemEdit
Event" do "copyMenuItem.ShortCutKeys = origKeys", however, I don't
like how the shortcut disappears in the menu with this method.

Is there an easy/simple alternative to my problem (select currently
highlight text method someplace? Something special with the ShortCut
system I can do with sender maybe to say I never handled the event and
to keep propgating it? Or something else to this problem that I don't
know about?

Thanks
 
N

NvrBst

ListView is in Detailed Mode, and an Item is in EditMode
(ListViewItem.BeginEdit()), how, if any, would I get the currently
highlighted portion of the text?

Basically I have a ctrl-c shortcut that copies the entire line of the
currently selected items, however, if the user is in Edit Mode I'd
like it just to copy what the user has selected (IE Default Behavior
of Ctrl-C).  If I ignore my copy method, "if(InEditMode) return;" then
the default behavior doesn't trigger; I'd need a "if(InEditMode)
{Handled=false; return;}" type thing which doesn't exist I don't
think, so now I'm trying to do "if(InEditMode) Copy Highlighted
Portion of listView1.SelectedItem[0].Text".

Another way would be when entering edit mode to do
"copyMenuItem.ShortCutKeys = Keys.None;" and in the "AfterItemEdit
Event" do "copyMenuItem.ShortCutKeys = origKeys", however, I don't
like how the shortcut disappears in the menu with this method.

Is there an easy/simple alternative to my problem (select currently
highlight text method someplace? Something special with the ShortCut
system I can do with sender maybe to say I never handled the event and
to keep propgating it?  Or something else to this problem that I don't
know about?

Thanks

Setting "copyMenuItem.Enabled = false;" and "copyMenuItem.Enabled =
true" is cleaner than re-setting the ShortCutKeys, and works better.
For future reference, I'd love to know how to grab the currently
selected/highlighted text on a Textbox/ListViewItem, etc. I assume
there has to be a .NET class (like Clipboard) which stores the
highlighted portion someplace?

Thanks
 

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