我们正在使用Infragistics作为自定义控件的基类。将使用此控件显示搜索结果的项目之一要求在未找到匹配项时显示用户友好的消息。
我们希望将该功能封装到派生控件中-因此,使用该控件的程序员除了设置要显示的消息外,不需要进行任何自定义。这必须以通用的方式完成-一种大小适合所有数据集。
UltraWinGrid中已经允许这种类型的使用了吗?如果是这样的话,我会发现它藏在哪里。:-)
如果需要对此功能进行编码,我可以想出一个算法,将空白记录添加到设置的任何记录集中,并将其放入网格中。在您看来,这是处理解决方案的最佳方式吗?
发布于 2009-08-13 19:10:52
我不知道这是否会有帮助,但在这里结束线程。我没有找到一种内置的方法,所以我解决了这个问题,如下所示:在继承UltraGrid的类中
Public Class MyGridPlain
Inherits Infragistics.Win.UltraWinGrid.UltraGrid我添加了两个属性,一个用于指定开发人员在空数据情况下想要表达的内容,另一个用于使开发人员能够将消息放在他们想要的位置
Private mEmptyDataText As String = String.Empty
Private mEmptyDataTextLocation As Point = New Point(30, 30)Public Shadows Property EmptyDataTextLocation() As Point
Get
Return mEmptyDataTextLocation
End Get
Set(ByVal value As Point)
mEmptyDataTextLocation = value
setEmptyMessageIfRequired()
End Set
End Property
Public Shadows Property EmptyDataText() As String
Get
Return mEmptyDataText
End Get
Set(ByVal value As String)
mEmptyDataText = value
setEmptyMessageIfRequired()
End Set
End Property我添加了一个方法,它将检查空数据,如果是,则设置消息。以及将移除现有空消息的另一种方法。
Private Sub setEmptyMessageIfRequired()
removeExistingEmptyData()
'if there are no rows, and if there is an EmptyDataText message, display it now.
If EmptyDataText.Length > 0 AndAlso Rows.Count = 0 Then
Dim lbl As Label = New Label(EmptyDataText)
lbl.Name = "EmptyDataLabel"
lbl.Size = New Size(Width, 25)
lbl.Location = EmptyDataTextLocation
ControlUIElement.Control.Controls.Add(lbl)
End If
End SubPrivate Sub removeExistingEmptyData()
'any previous empty data messages?
Dim lblempty() As Control = Controls.Find("EmptyDataLabel", True)
If lblempty.Length > 0 Then
Controls.Remove(lblempty(0))
End If
End SubLast -我在网格的InitializeLayout事件中添加了对空数据的检查。
Private Sub grid_InitializeLayout(ByVal sender As Object, _
ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) _
Handles MyBase.InitializeLayout
setEmptyMessageIfRequired()
End Subhttps://stackoverflow.com/questions/892760
复制相似问题