Hi,
I've got an UltraWinGrid hooked up to a BindingSource.
One of my source's columns/properties is of type Nullable(Of Integer).
I have set the column's ValueList property, and the ValueList includes an entry generated by the line "ValueList.ValueListItems.Add(DBNull.Value, "")"
I have set the following settings on the Column:
Column.ValueList = MyValueList Column.NullText = String.Empty Column.Format = String.Empty Column.Nullable = Infragistics.Win.UltraWinGrid.Nullable.Nothing Column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList Column.Header.Caption = "myCaption"
In my dropdown, when the list is dropped down, the blank value shows as an empty option in the list. If I select this option and the cell is still selected, an empty cell is displayed.
When I click off the list, the cell suddenly displays a "0". When I re-focus the cell and the dropdown opens again, the 0 is still displayed in the cell itself, but the entry in the dropdown list is still a blank entry. Clicking on the blank entry again blanks the cell again, until it loses focus, when it displays 0 again.
I've searched the forum and I can't find any solution except for this guy http://ko.infragistics.com/community/forums/t/75962.aspx and he doesn't say how he solved his problem.
EDIT: I've just noticed that the "DisplayString" of the ValueList item is being set to "0" instead of an empty string, which I suspect is the root of the problem, but I'm not sure how to deal with it.
There's no "DisplayString" property on ValueListItem. I assume you mean DisplayText?
Fixing this is probably just a matter of changing the DisplayText. The DisplayText of the item is whatever you set it to when you populated the ValueList, or if you bound the ValueList to a DataSource, then it comes from the DisplayMember property in your data.
If that's not helpful, then perhaps you could post a small sample project demonstrating the problem and I would be happy to take a look at it.
BTW... is there any particular reason you are using Nullable(Of Integer) instead of just Integer? If your data source is a DataSet, DataTable, or UltraDataSource (with or without a BindingSource), then you don't need to use a Nullable type - the data source will already allow you to support nulls.
Thanks for the reply.
I find ValueItem.DisplayString when examining the problematic ValueItem in the debugger. This exposes a ReadOnly Friend Property of the ValueItem, called "DisplayString".
This DisplayString field is String.Empty at the time the relevant ValueItem is created, and it is still String.Empty after I set Column.ValueList = myValueList, but at some point (presumably when the WinGrid is being displayed) it is this field that is being set to "0". ValueItem.DisplayText is never set to "0", it always remains as String.Empty.
We don't use DataTable here because of legacy issues with database communication methods. We're evaluating switching to another data access method, but for the moment we use an in-house data container.
I'm binding that to the grid via:
Private myDataMappings As List(Of DataMapping) Dim myBindings As New System.ComponentModel.BindingList(Of DataMapping)(myDataMappings) Dim mySource As New Windows.Forms.BindingSource() mySource.AllowNew = True mySource.DataSource = myBindings grdMyMappings.DataSource = mySource
and allowing the WinGrid to bind to the Properties of the object.
Like I said, though, DisplayText of the ValueItem is always String.Empty. It is the ReadOnly Friend Property DisplayString that is being set to "0", and I can't work that out at all.