2009-05-21 66 views
1

我們使用的Infragistics UltraWinGrid爲自定義控件的基類。其中一個將使用此控件顯示搜索結果的項目需要在未找到匹配項時顯示用戶友好的消息。Infragistics的UltraWinGrid EmptyDataText等效?

我們想封裝了功能集成到衍生控制 - 因此沒有定製超出設定顯示由誰使用控制程序員所需要的信息。這必須以通用的方式完成 - 一種尺寸適合所有數據集。

是否有津貼的UltraWinGrid此類用法已經嗎?如果是這樣,我會在哪裏發現它隱藏。 :-)

如果此功能需要進行編碼,我能想到的算法將添加一個空白記錄到任何記錄設置和地點到電網。您認爲,這是處理解決方案的最佳方式嗎?

回答

2

我不知道這是否會幫助,但這裏整理了線程。我沒有找到一個內置的方式,讓我解決了這個問題,如下所示:在我的課堂它繼承的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 Sub 

最後 - 我加空數據的檢查,以網格的InitializeLayout事件。

Private Sub grid_InitializeLayout(ByVal sender As Object, _ 
     ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) _ 
     Handles MyBase.InitializeLayout  

    setEmptyMessageIfRequired() 

End Sub 
相關問題