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.
Hello Kristian,
I am just checking about the progress of this issue. Let me know if you need my further assistance on it.
Thank you for using Infragistics Components.
I am having the same issue. The code is very simple.
public partial class KitMaintenanceView : UserControl {
public KitMaintenanceView() { InitializeComponent(); _valueListParts = new ValueList {FormatString = string.Empty}; _valueListParts.ValueListItems.Add(1, "First item"); ValueListItem item = new ValueListItem(2,"Second item"); _valueListParts.ValueListItems.Add(item); setupHandlers(); }
private void grdKit_InitializeLayout(object sender, InitializeLayoutEventArgs e) { e.Layout.GroupByBox.Hidden = true; e.Layout.TabNavigation = TabNavigation.NextControlOnLastCell;
// Resize columns to width of grid e.Layout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
e.Layout.Override.CellClickAction = CellClickAction.Edit; e.Layout.Override.AllowAddNew = AllowAddNew.FixedAddRowOnTop; e.Layout.Override.AllowUpdate = DefaultableBoolean.True; e.Layout.Override.AllowDelete = DefaultableBoolean.True;
UltraGridBand bandKit = e.Layout.Bands[0]; UltraGridBand bandParts = e.Layout.Bands[1];
// Make row selectors visible bandKit.Override.RowSelectors = DefaultableBoolean.True; // Customize the appearance of the row selectors. e.Layout.Override.RowSelectorAppearance.BackColor = Color.Cyan;
// Hide columns parent band bandKit.Columns["Id"].Hidden = true;
// Hide columns child band bandParts.Columns["Id"].Hidden = true; bandParts.Columns["KitId"].Hidden = true;
// Set Column descriptions, widths & appearances for child band bandParts.Columns["PartId"].Width = 450; // band.Columns["PartId"].SortIndicator = SortIndicator.Ascending; bandParts.Columns["PartId"].Header.Caption = "Description"; bandParts.Columns["PartId"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; bandParts.Columns["PartId"].ValueList = _valueListParts;
bandParts.Columns["Quantity"].CellAppearance.TextHAlign = HAlign.Right; bandParts.Columns["Quantity"].Format = "###,##0.00"; bandParts.Columns["Quantity"].MaskInput = "999999.99"; bandParts.Columns["Quantity"].Width = 70; }
private void setupHandlers() { grdKit.InitializeLayout += grdKit_InitializeLayout; }
}
Hello Lars,
Thank you for posting in our forum.
Following the steps you have described and using the code snippet you have provided I have implement a custom control. I have populated this custom control with some sample data and have added in a sample Windows Forms application. I have run my sample application and I did not have any zeros in my grid. Please note my test application was build with latest version of Infragistics Controls 15 Volume 1, 15.1.20151.2013.
I am sending you my sample project in order to test it on your machine, and let me know if you experience the same issue or not. If the issue appears again this could be because of different version of Infragistics Controls we are using, so please let me know the exact version of your controls. If the issue does not appear this could be an issue in your code, so please try to send me an small isolated sample demonstrating this behavior. If you do not have such sample please fill free to modify my sample solution to match your scenario and send it back to me.
Looking forward to your reply.
I cannot figure out why yours is working and mine is not. Perhaps because I'm running NetAdvantage 14.2?
I tried to make my sample as simple as possible and yet with similar data to the real solution. I constructed a Form sample rather than UserControl. I changed the ComboBox from a ValueList to an EditorComponent, yet the result is the same. Maybe it's because there are almost 9K items in the Combo editor?
Also, if I type data into the Editor portion of the ComboBox for which there is no corresponding item, I get an error message (in attached archive - combo_error.png).
Finally, the combo drop down does not seem to work with the settings in its initialize event handler: AutoCompleteMode.SuggestAppend and AutoSuggestFilterMode.Contains. If I try to type in the Editor of the combo with a string which does not exist at the beginning of the DisplayMember, it is slow and finds nothing.
Thank you for your feedback.
Please find bellow answers to your questions:
I changed the ComboBox from a ValueList to an EditorComponent, yet the result is the same. Maybe it's because there are almost 9K items in the Combo editor? – this should not be an issue. Please check the attached sample with 10 000 items not reproducing this behavior;
Also, if I type data into the Editor portion of the ComboBox for which there is no corresponding item, I get an error message – this is expected behavior. You need to choose an item from the dropdown or you need to enter an integer. If you enter a value not existing in the drop down list and not an integer it cannot be parsed to the value of the column.
Finally, the combo drop down does not seem to work with the settings in its initialize event handler: AutoCompleteMode.SuggestAppend and AutoSuggestFilterMode.Contains – you need to set all this properties to the grid column and not to the combo. Actually the grid uses the combo’s editor and not the combo itself. Please check the attached sample where I have set all this properties to the grid column.
Please note I still cannot reproduce this behavior at my side. The only difference is the getPartsList method. As I did not find the parts.json file I have change this method in order to be able to run your sample. If you can send me this file I will be happy to test with it.