2011-11-10 33 views

回答

1

隨着Infragistics的你有很多的選擇如何實現這一功能。 讓我告訴你最簡單的方法:

  1. 設置列的屬性後,您將Grid.DataSource屬性:
UltraGridColumn c = null; 
/// initialize c here. Lets suppose that it has a "rtf" key. 
c.Style = ColumnStyle.FormattedTextEditor; 
((FormattedLinkEditor) c.Editor).UnderlineLinks = UnderlineLink.Always; 
((FormattedLinkEditor)c.Editor).LinkClicked += new Infragistics.Win.FormattedLinkLabel.LinkClickedEventHandler(rtfColumnn_LinkClicked); 
c.MaskClipMode = MaskMode.Raw; 
((FormattedLinkEditor) c.Editor).TreatValueAs = TreatValueAs.FormattedText; 
  1. 允許用戶打開RTF文本鏈接:
private void rtfColumnn_LinkClicked(object sender, Infragistics.Win.FormattedLinkLabel.LinkClickedEventArgs e) 
{ 
    e.OpenLink = true; 
} 
  1. 訂閱事件BeforeEnterEditMode
bindingGrid.BeforeEnterEditMode += this.Grid_BeforeEnterEditMode; 
  1. ,並顯示出很好的Infragistics RTF編輯器,而不是盒內編輯:
private void Grid_BeforeEnterEditMode(object sender, System.ComponentModel.CancelEventArgs e) 
{ 
    if (Grid.ActiveCell.Column.Key=="rtf") 
     { 
      Infragistics.Win.SupportDialogs.FormattedTextEditor.FormattedTextUIEditorForm rtf_frm = 
       new FormattedTextUIEditorForm(); 
      rtf_frm.Value = Grid.ActiveCell.Value; 
      DialogResult dresult = rtf_frm.ShowDialog(); 
      if (dresult == DialogResult.OK) 
      { 
       Grid.ActiveCell.Value = rtf_frm.Value; 
      } 

      e.Cancel = true; 
      return; 
     } 
} 
相關問題