I set a dropdown as the ValueList for one of my columns. It now takes 10 times as long to load up my grid. It also takes 4 seconds just to move from row to row in the grid.
The grid has about 30 rows in it, and the dropdown has about 249. The DataSource of the dropdown is a SQL Server view via a BindingSource.
How can I get decent performance in this scenario?
Hi,
This is a dilemma the grid faces occasionally. For some functionality, the grid simply does not know whether to use the display text or the data value. In the case where you have a value list, the grid leans toward the display text for anything the user can see.
For example, if you are sorting the column, the grid will sort by display text because most of the time the user will expect the data to be sorted in a way that they understand - alphabetically. The user doesn't know that there is a data value underlying the column, all they see are strings. So sorting by the value would be a weird, arbitrary way to sort.
Similarly, when using a ValueBasedAppearance, you might have several DisplayTexts on your list with the same value. So it might seem odd to a user that the same appearances is applied to cells with different text - since the user doesn't necessarily know that they have the same underlying value.
I made it a FormulaCondition since Value of OperatorCondition would not let me enter a string and it works right. The formula editor dialog would not allow me to select the column name, but I was able to simply enter it as text in the formula.
[TaskID] = "0"
Great work. Thanks a bunch.
So, my ValueBasedAppearance should compare to the DisplayMember, rather than the ValueMember?
I looked at your test app and I see the problem. If you set the Visual Studio IDE to break on all run-time exception, you will see that there are exceptions occurring every time the TaskId cell tries to paint. The exceptions are being caught by the grid, so normally you don't see them. But caught exceptions slow down the app considerably.
So... why are there exceptions being raised? It turns out that this is not a problem with your ValueList or UltraDropDown - at least not directly. The problem is the ValueBasedAppearance you have applied to the TaskId column. Your condition is looking for a numeric value, but your column is not displaying numeric values, it's displaying strings thanks to the ValueList. So every time the grid paints, it's trying to convert the string in this cell into a numeric value to match up with your ValueBasedAppearance and failing.
So you need to change your ValueBasedAppearance to look for a string instead of a numeric value. Or maybe handle InitializeRow and apply the appearances yourself based on the Value of the cell.
I also found that if my display-member and value-member is the same, then the performance is fine.