URL单元中的未定义协议

问题描述 投票:0回答:1

我有一个样式等于Infragistics.Win.UltraWinGrid.ColumnStyle.URL的UltraGridCell,并将我自己的处理程序添加到UltraGrid.MouseClick,以便在单击URL列时可以打开一个新选项卡

如果URL列的值为“ ABCDE”,则没有错。它看起来像单元格中的URL链接,带有下划线和蓝色(单击后变为紫色)。就像浏览器中的URL链接一样。

问题是,如果内容的值类似于“ ABC:DE”。事实证明,它抱怨正在调用一个未定义的协议。就像您在IE URL栏中输入“ ABC:// DE”一样。

enter image description here

在调试模式下检查后,看来应该由UltraGrid在内部调用它。因此,我的问题是:我有什么办法可以禁用此默认行为?

非常感谢您的帮助。

infragistics
1个回答
0
投票
当您将列样式设置为Infragistics.Win.UltraWinGrid.ColumnStyle.URL时,列的编辑器将变为Infragistics.Win.FormattedLinkLabel.FormattedLinkEditor。该编辑器具有LinkClicked事件。在事件处理程序中,您可以获取事件参数的OpenLink属性并将其设置为false。这将抑制链接打开。为此,请首先在InitializeLayout事件中获得编辑器:

private void UltraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { // get the column you will set up var column = e.Layout.Bands[YOUR_BAND_INDEX].Columns[YOUR_COLUMN_INDEX]; // set the style of the column (you already did this) column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.URL; // get the editor after set the column style and handle LinkClicked event var editor = column.Editor as FormattedLinkEditor; editor.LinkClicked += this.Editor_LinkClicked; }

然后在LinkClicked事件中停止链接打开:

private void Editor_LinkClicked(object sender, Infragistics.Win.FormattedLinkLabel.LinkClickedEventArgs e) { e.OpenLink = false; }

© www.soinside.com 2019 - 2024. All rights reserved.