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?
fweeee said:I dont understand the bit about translating DataValues into DisplayValues.
What I mean by this is... are you setting the DataMember and DisplayMember property on the UltraDropDown to two different columns (or to the same column, for that matter). These allow you to store one value (DataMember) while displaying some more user-friendly text (DisplayMember) to the user.
fweeee said: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?
Without seeing the behavior occur, it's hard to say. I would start with the BeforeMultiCellOperation event. This is the event that fires when you paste multiple cells in the grid. There's also an AfterMultiCellOperation, but I'm not sure that's helpful here.
Mike Saltzman"]What I mean by this is... are you setting the DataMember and DisplayMember property on the UltraDropDown to two different columns (or to the same column, for that matter). These allow you to store one value (DataMember) while displaying some more user-friendly text (DisplayMember) to the user.
OK. Yes I am. I'm setting them both to the same property of the lookup dataitme.
Mike Saltzman"]Without seeing the behavior occur, it's hard to say. I would start with the BeforeMultiCellOperation event. This is the event that fires when you paste multiple cells in the grid. There's also an AfterMultiCellOperation, but I'm not sure that's helpful here.
The BeforeMultiCellOperation is not being fired. Keep in mind, I am pasting only into a single cell. Should it be getting fired?
fweeee said:OK. Yes I am. I'm setting them both to the same property of the lookup dataitme.
Just as a test, try setting only the ValueMember and not the DisplayMember. DisplayMember will fall back to ValueMember if DisplayMember is not set.
fweeee said:The BeforeMultiCellOperation is not being fired. Keep in mind, I am pasting only into a single cell. Should it be getting fired?
Okay, if you are pasting into a single cell and that cell is in edit mode, then none of the events you listed here will fire until you leave the cell. The only event that would fire immediately in that case would be the CellChange event. That's the event that fires when you are in the process of modifying a cell in edit mode. My gues is that the text you are pasting into the cell is getting cleared because it doesn't match any of the items on the list and the data type of the column can't handle a string.
What's the DataType of the column?
And what is the DataType of the ValueMember and DisplayMember fields on the UltraDropDown?
Also, does the text you are pasting exactly match an item in the DisplayMember field of the UltraDropDown? Be sure to check for leading or trailing spaces.
Oh, one more thing.., you should try trapping the Error and / or CellDataError events of the grid and see if either of these events are firing when you leave the cell.
Mike Saltzman"]Just as a test, try setting only the ValueMember and not the DisplayMember. DisplayMember will fall back to ValueMember if DisplayMember is not set.
I cant try it right now, but will in 12 or so hours. I doubt it will have much impact - in my sample app that I made, i was doing the same - setting DisplayMember and ValueMember to the same field.
Mike Saltzman"]Okay, if you are pasting into a single cell and that cell is in edit mode, then none of the events you listed here will fire until you leave the cell.
Thats right. And they dont, if the cell value is null to begin with.
Mike Saltzman"]The only event that would fire immediately in that case would be the CellChange event.
Yep - and it doesnt.
Mike Saltzman"]My gues is that the text you are pasting into the cell is getting cleared because it doesn't match any of the items on the list and the data type of the column can't handle a string.
Note quite. When I paste text which matches a value in the dropdown, it does not stick. When I paste a value which *isnt* in the list, it does (well, it fires the event in which I check if there a matching values in the list, the UltraGrids "BeforeCellUpdate" event).
Mike Saltzman"]What's the DataType of the column?
The columns that are not working are of datatype String. The ones that are of datatype int? or long?.
Mike Saltzman"]Also, does the text you are pasting exactly match an item in the DisplayMember field of the UltraDropDown? Be sure to check for leading or trailing spaces.
Yes, they match completely. No trialing zero's. If they did not match completely, it would prompt me to add the value (it does if I paste in something not in the list).
Mike Saltzman"]Oh, one more thing.., you should try trapping the Error and / or CellDataError events of the grid and see if either of these events are firing when you leave the cell.
I think I am, but have not seen them getting fired. Again, I'll double check this later.
---- EDIT ----
I've managed to do some testing now. No, only setting the ValueMember and not the DisplayMember makes no difference.
None of the events CellChange, CellDataError, or Error are called when I paste a value in, and tab out.
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.