Infragistics UltraWinGrid EmptyDataText Equivalent?

We are using Infragistics UltraWinGrid as a base class for custom controls. One of the projects that will use this control to display search results should display a user-friendly message if no matches are found.

We would like to encapsulate this functionality in a derived control, so the programmer who uses the control does not need to be configured outside of the display message setting. This should be done in general terms - one size fits all datasets.

Does UltraWinGrid have permission for this type of use? If so, where do I find it hidden. :-)

If this functionality needs to be coded, I can come up with an algorithm that will add an empty record to any recordset and put it on the grid. In your opinion, is this the best way to handle the solution?

+1


a source to share


1 answer


I don't know if this helps, but here's to end the thread. I didn't find a built-in way, so I solved this problem as follows: In my class that inherits UltraGrid

Public Class MyGridPlain
Inherits Infragistics.Win.UltraWinGrid.UltraGrid

      

I added two properties, one to indicate what the developer wants to say in the empty case, and another so that the developer can place his message wherever he wants.

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

      



I added a method that will check for empty data and if so, set a message. And one more method that will remove the existing empty message.

    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

      

Last - I've added a check for empty data to the InitializeLayout event of the grid.

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

     setEmptyMessageIfRequired()

End Sub

      

+2


a source







All Articles