0

我正在做我的项目,我正在为自己制作记事本。目前我处于最终状态(修复错误并添加一些最终的东西)。我现在面临的问题是:当我粘贴格式化的文本时,它保持格式化,我希望它未格式化,默认字体,默认大小。我m 在 Microsoft Visual 2010 C++ 中工作。我用于粘贴的代码:

private: System::Void pasteToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
         richTextBox1->Paste();
     }
4

1 回答 1

0

Paste方法有这个重载,它接受一个参数来指定粘贴数据的格式。指定您想要的格式,例如DataFormats::TextDataFormats::UnicodeText。例如:

  // Get the format for the object type.
  DataFormats::Format^ myFormat = DataFormats::GetFormat( DataFormats::Text );

  // After verifying that the data can be pasted, paste it. 
  if ( richTextBox1->CanPaste( myFormat ) )
  {
     richTextBox1->Paste( myFormat );
     return true;
  }
  else
  {
     MessageBox::Show( "The data format that you attempted to paste is not supported by this control." );
     return false;
  }
于 2015-04-26T20:20:11.710 回答