Peter -- See http://discuss.develop.com/archives/wa.exe? A2=ind0110c&L=dotnet&F=&S=&P=8043
This will work in an MDI WinForm. Bill On Thu, 11 Apr 2002 13:21:05 -0700, Peter Stephens <peter- [EMAIL PROTECTED]> wrote: >Unlike FoxPro or MFC there doesn't seem to be any automagic support for the >standard edit commands in a main menu. The textbox does have a context menu, >but there doesn't seem to be a way to associate that with a main menu or a >merge menu (in MDI). > >I have an idea for a method that might work: > >------> >bool AllowCut() >{ > TextBox textBox = GetCurrentControlAsTextBox(); > if(textBox == null) return false; > > // Do we have text to cut? > return textBox.SelectionLength > 0; >} > >void CutText() >{ > TextBox textBox = GetCurrentControlAsTextBox(); > if(textBox == null) return; > > // Cut the text > if(textBox.SelectionLength <= 0) return; > Clipboard.SetDataObject(textBox.SelectedText); > textBox.SelectedText = ""; >} > >// Return active control if it is a textbox, otherwise null >TextBox GetCurrentControlAsTextBox() >{ > Form activeWin = ActiveMdiChild; > if(activeWin == null) return null; > Control activeControl = activeWin.ActiveControl; > if(activeControl == null) return null; > return activeControl as TextBox; >} > ><------ > >These routines would be wired into a main MDI window. >This code has _NOT_ been tested and might not work, but it is where I will >start. Better ideas are welcome! > >-- >Peter > >You can read messages from the DOTNET archive, unsubscribe from DOTNET, or >subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.