Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / UltraGrid displaying Null and Empty values

UltraGrid displaying Null and Empty values

New Discussion
Bruno
Bruno asked on Aug 29, 2018 11:16 AM

Hi All,

I have some columns that can be filled with a Null value or an Empty value.

All I want is to let the user choose what the value of the cell:

– if the cell is cleared then the value should be empty (shown as empty/blank)

– if the cell is filled with “NULL” text then the value should be DbNull.value (shown with text “NULL”)

I have tried to set this with a EditorDataFilter but it doesn’t seems to work and I don’t know if it is the right way to procede.

Is there any proper way to achieve this ?

Sign In to post a reply

Replies

  • 0
    Michael Peterson
    Michael Peterson answered on Aug 28, 2018 7:52 PM

    Hello Bruno,

    Thank you for contacting Infragistics!

    The behavior of an empty/blank cell being displayed when the value is cleared out is the default behavior. To have the null text be “Null” you can set the “UltraGrid.DisplayLayout.Override.NullText” to “NULL”. As for setting null when the user enters “NULL” I would recommend handling the AfterExitEditMode or BeforeExitEditMode event of the grid and if the text is “NULL” set the value to null.

    • 0
      Bruno
      Bruno answered on Aug 29, 2018 11:16 AM

      Hi Mike,

      Thank you very much, this is indeed working [emoticon:6d505171faa4497c85c5ca27290c555d]
      For anyone interested, here is the implementation :

      Public Sub New()
      	myUltraGrid.DisplayLayout.Override.NullText = "NULL"
      End Sub
      
      Private Sub myUltraGrid_AfterExitEditMode(sender As Object, aArgs As EventArgs) Handles myUltraGrid.AfterExitEditMode
      	'get new value of the cell
      	Dim newCellValue As Object = myUltraGrid.ActiveCell.Value
      	
      	'set DBNULL if value is "NULL"
      	If newCellValue.GetType() = GetType(String) then
      		Dim strCellValue as string = CStr(newCellValue)
      		If strCellValue = "NULL" then
      			myUltraGrid.ActiveCell.Value = DBNull.Value
      		End If
      	End If
      End Sub

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Bruno
Favorites
0
Replies
2
Created On
Aug 29, 2018
Last Post
7 years, 7 months ago

Suggested Discussions

Created by

Created on

Aug 29, 2018 11:16 AM

Last activity on

Feb 23, 2026 10:25 AM