I've just upgraded my winforms controls from v8.2 to v12.1. Since the upgrade, some cells in the UltraGrid are not behaving correctly.
When I paste a valid value into them, they display just fine, until I tab out of it, in which case it loses its value.
The cells in question have a dropdown control on them. Not all cells with dropdowns have this issue though. As best as I can tell, the only real difference between the dropdown cells that work fine, and the ones that do not, is the ones that do not have the datatype string behind them, while those that work fine have the datatype of int behind them.
What could be causing this?
A little more information - if the string dropdown already has a value in it, then paste works fine. Its only if it initially has a value of null that causes problems.
--- EDIT ---
Bit more information. The CellChange event does not fire if the cell is a blank string in it originally. But after it has a value (by selecting from the dropdown) it fires fine.
Hi,
What kind of DropDown is in the cell? Is it a ValueList or an UltraDropDown?
You say that this only happens if the DataType of the grid column is string and the field is initially null?
Is the dropdown translating DataValues into DisplayValues?
Can you duplicate the issue in a small sample project and post it here so we can check it out? I tried creating a sample, but there are just too many unknowns for me to get it right.
It is an UltraDropDown, which I am programatically assigning to the ValueList, like so:
ultraGrid.DisplayLayout.Bands[0].Columns["ColumnName"].ValueList = Brandmngt.CreateDropDown(jobItemGridValidationMngt.DropDownSelectedmngt, null, true, true);
The Brandmngt class is one that I use on numerous forms, where I need to generate this dropdown. It reads data from the database, formats the dropdown, add required events, etc.
Yes - only for the string columns, and only if they are currently null.
I dont understand the bit about translating DataValues into DisplayValues.
I have tried to reproduce the problem in a small sample project, but could not. It worked as you would expect there.
Another thing I have just found. I just tried pasting in an invalid value, and it displayed. When I left the field, it ran the code I wrote to handle this (in the grids BeforeCellUpdate event). But when I paste a value into it, the BeforeCellUpdate event is not triggered.
Its looking like some of my other code (in the grid management/validation side ofthings) is suppressing these events. I'm going to have to try delving through that. Its frustrating that this is happening - that the behaviour of the grid has changed so that it breaks old code.
Nope. Cant find anything. Neither the AfterCellUpdate nor the CellChange events are firing.
Can you give me a hint at what I should be looking for? Is there some sort of cancel update or something that I could be calling somewhere that is causing this?
OK. I think I have something now. It seems the critical detail is the AutoCompleteMode of the grid column to Default.
If you set it to SuggestAppend (which I have), you get this issue.
Is this a bug? It looks like it to me.
I had a similar problem when I last upgraded. From memory, to solve the bug when I upgraded to v8.2, I had to change the AutoCompleteMode to SuggestAppend.
Is this issue likely to get looked at? Is it a problem in later versions? I'm licensed for the next version on, but am hesitant to move to .net 4.0, as I'll need to upgrade my installer.
I tried this out and I am not able to reproduce the issue. It works just fine foe me with SuggestAppend. I have attached my sample project here so you can see if you get the same results.
Yes, that worked fine for me to. But you seem to be doing things slightly different to me.
I have attached my sample, using visual studio 2008. Try pasting "ONE" or "TWO" into the StrColumn column.
I'm not exactly sure why, but the problem in your sample is here:
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { e.Row.Cells["StrColumn"].ValueList = strLookupMngt.CreateDropdown(); }
This is bad for a number of reasons. For one thing, this is extremely inefficient. This event fires every time any cell value in any row changes. So you are unnecessarily creating and recreating the a new UltraDropDown control with the same data for every row multiple times.
And, if the inefficiency is not bad enough, setting the UltraDropDown over and over is what's causing the cell to blank out. My guess is that there's some kind of timing problem here where the grid is trying to match up the text to something on the list and it can't because the list has changed in the middle of the process.
If I change your sample to create the DropDown once and assign it to the cell once, it works fine.
I assume that, in your real app) you are assigning a dropdown to the cell instead of the column for a reason. So you probably need to use InitializeRow. But you should not be creating a new UltraDropDown control every time. Instead, it would be best to cache the UltraDropDown and re-use the same one. And, in fact, you could re-use the same UltraDropDown for all the cells that need to show the same list - you don't need one for every cell.
Yes, there is a reason I use the InitializeRow event to set some dropdowns, because the value of the list depends on other values in the row, which may change. But what you see in this sample app is very different to the live app. In the live app, a list of possible dropdowns is maintained, and the dropdown is only changed if the correct one is not assigned. So the dropdown is not constantly changing - its just being set in the InitializeRow event.
To more closely simulate this, you can changethe InitializeRow event as follows:
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { if (e.Row.Cells["StrColumn"].ValueList == null) e.Row.Cells["StrColumn"].ValueList = strLookupMngt.CreateDropdown(); }
For me, the issue still occurs if I do this.
To take it one step further, and only use the InitializeLayout event, like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { ultraGrid1.DisplayLayout.Bands[0].Columns["IntColumn"].ValueList = intLookupMngt.CreateDropdown(); ultraGrid1.DisplayLayout.Bands[0].Columns["StrColumn"].AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend; ultraGrid1.DisplayLayout.Bands[0].Columns["StrColumn"].ValueList = strLookupMngt.CreateDropdown(); }
While the InitializeRow event does nothing. I still get the issue.
Hi Harshit,
I replied to this question on Wednesday here.
Hi Mike,
I have implemented Ultradropdown in my wingrid and it is working perfectly fine. The issue occurs when I copy an alphanumeric/numeric value and paste it into the ultradropdown box, it pops up the error message [Unable to convert from "System.String" to "System.DateTime"]. I tried to debug the code but I was unable to find from where this message is getting triggered.
Please note that it is not a date-time type text box and there is no error message when I paste an alphabetical value. Also, after this error message, the value gets entered (pasted) as expected. It's just that I need to modify this message to some user friendly message like "copy/paste is not allowed for this field".
Kindly help me out.
Thanks,Harshit
Hello,
This issue has been addressed in service release versions WinForms_13.1.20131.2040, WinForms_12.2.20122.2087.
I can't say for certain until we've looked into it. But in my opinion, this looks like a bug and it will probably be fixed in an upcoming service release. If, for some reason, a fix is not feasible, then we would at least try to provide you with a reasonable workaround.