Hi
I upgraded a visual basic project from infragistics version 2003 to 2010.2
I removed all errors and warnings and could successfully run the project.
But my code breaks with different errors when a ultra combo box's value or text property is set using code.
For example,
If my previous code has assigned value property:
UltraComboBox.value = 0
It throws error "Object reference not set to the instance of an object" Commenting this code allows application to run.
If my previous code has assigned text property:
UltraCombobox.Text = ""
It throws error "Object reference not set to the instance of an object" Replacing "" with Nothing allows the code to run.
Has value and text property assignment changed over infragistics versions?
Thanks
Shivangi
Hi Shivangi,
What object is null when the exception occurs? Can you post the call stack of the exceptions?
Hi Mike,
Here is the call stack for UltraCombo Value changed:
System.NullReferenceException occurred
Message="Object reference not set to an instance of an object."
Source="Infragistics2.Win.UltraWinGrid.v10.2"
StackTrace:
at Infragistics.Win.UltraWinGrid.UltraGridBase.OnTextChanged(EventArgs e) at Infragistics.Win.UltraWinGrid.UltraCombo.OnTextChanged(EventArgs e) at Infragistics.Win.UltraWinGrid.UltraCombo.FireTextChangedEventHelper(Boolean hasChanged, String newText) at Infragistics.Win.UltraWinGrid.UltraCombo.SelectedItemChangeHelper(ComboSelectedItemChangeContext context, Object newData) at Infragistics.Win.UltraWinGrid.UltraCombo.set_Value(Object value) at ProjectName.FormName.ComboBoxName_ValueChanged(Object sender, EventArgs e) in C:\Documents and Settings\Visual Studio 2008\Projects\ProjectName\ProjectName\FormName.vb:line 1234
InnerException:
Thanks,
I looked more at the code written with earlier version,
and the reason coder used .Value = 0 and .Text = " " was to default text properties to nothing, so that previous values are removed and you do not see anything in the text box.
I am not sure, but is it changed over the years for infragistics?
How should you assign "Nothing" for value and text properties of UltraCombo and TextBoxes?
There's nothing wrong with the code you have here. I cannot even begin to guess what might have changed in the 7+ years in between the two versions you were using. This could have been a bug that was fixed or it might just be some unintentional change in behavior, but there's really no way to tell without seeing it in action.
Do clear the value from the Combo, you would typically set the Value to null (Nothing), rather than 0, but this depends on the data that is on the list. It certainly should not be necessary to set both the Value and the Text. One or the other should be sufficient.
What is the DropDownStyle of the Combo set to?
Are you able to duplicate this behavior in a small sample project and post it here so I can check it out?
Thanks for the response Mike,
I can not change database as it has years old data which I do not want to modify.
Here's how I solved the problem:
if ddlXYZ.Value = 0 then
ddlXYZ.Value = DBNull.Value
ddlXYZ.Text = Nothing
End If
If the DataType you are binding to is an Int and it cannot accept nulls, than that is probably the problem right there.
One way to deal with that would be to place an item on the list that matches up a DataValue of 0 with no text or maybe an empty string or a string with single space character in it.
Setting Nullable to true might work, also.
The DropDownStyle is DropDown to have multiple text search. Is there an option in new DropDownList style where it can search for multiple text (not only data that starts with that one letter)?
No, all dropdowns do not have any value with 0 but as DropDownStyle is DropDown it still shows 0 in textbox.
I found another reason for this text = 0: When Null / Nothing is written back to SQL database to store data it stores 0 (DataType is Int). Thus when it reads data it shows 0 in text as well.
Hi,
I'm afraid I cannot explain why the exception is occurs when you set the Value of the Combo to 0. But if the DropDownStyle is set to DropDownList, then any Value you set must exist on the list r it will not be valid. Is there an item on the list with a DataValue of 0? If not, then this should never have worked.
I also don't see how the Combo could be retaining the original text when you set it's Value to Null, but perhaps all you need to do is set the Nullable property on the control to allow nulls.
Hi Mike
I do understand it is going to be a challenge making 7+ year old code compatible with new versions.
While I am trying to duplicate the whole problem in small application, let me clarify what this code is suppose to do and may be I can totally re-write that part of code with new version.
I have 4 comboboxes with multiple columns dependant on each-other (i.e. 2nd combobox depends on 1st, 3rd depends on 2nd and 4th depends on 3rd).
Whenever value of first combobox' is changed, all the other comboboxes should show Blank-null-nothing in their textboxes but still have corresponding values in dropdown. When 2nd comboboxe's value is changed 3rd and 4th comboboxes should reset and still have corresponding values in dropdown and so forth.
To achieve this (reset value/text to nothing) Value property of combobox is assigned 0 in old code (ComboBox.Value = 0).
Now if I keep same code in new version, it either throws reference not set error or shows “0” in text of combobox.
If I change .Value = 0 to .Value = nothing, it keeps old text in textbox.
The dopdown style is “DropDown” for all comboboxes.
It is a huge application with a lot of inter dependant modules, I would try my best to create a sample code.