Replies
Setting this propery fixed my issue:
ultraGrid1.SyncWithCurrencyManager = false;
Thanks. I tried this, but it didnt have much impact – I have still seen that error once or twice since.
Worse still, it also stopped binding source events firing for the grid. I use those extensively. Took me a while to work out what was wrong.
I think it is just a matter of painfully looking for the real cause of the errors, and getting rid of those.
Mike,
Thanks for your help – I've sorted out all of my (current) issues with this.
I did as you suggested (Setting an Editor to the column), but this did not resolve the issue.
After spending some time constructing a small application demonstrating the issue, I realised that the problem was with Console.Writeline. I was using this in the DataFilter code to help me sort out issues, and had not removed it yet. I didnt think this would be significant, but by my calculations, each call to Console.Writeline was adding about 0.09 seconds of overhead (well, slowing it down by 0.09 seconds). This quickly adds up while scrolling thorugh hundreds of records.
Thanks for your help.
I looked for run-time exceptions (as you suggested), and it found none. So the overhead must be elsewhere.
As an experiment, I set up a DataFilter which returns null (so it doesnt actually do anything). When I tried scrolling thorugh records, it slowed down the scrolling by more then a half without any datafilter (Or is that less then half? Well, slower then half the speed).
Which leads me to think I'm not setting the datafilter right in the first place. The examples are kind of light on the ground, so I had to improvise.
What I have done:
1) Create a new class, that looks a little like this (I am returning null right now):
818 public class GridCurrencyDataFilter : Infragistics.Win.IEditorDataFilter
819 {
820 /// <summary>
821 /// Converts Currency fields for display in edit mode
822 /// </summary>
823 /// <param name="conversionArgs">Input arguments.</param>
824 /// <returns>Converted data.</returns>
825 public object Convert(Infragistics.Win.EditorDataFilterConvertArgs conversionArgs)
826 {
827 return null;
2) When the user opens a form, the code is cycling through all of the columns in all the bands of the UltraGrid. Any that it finds have a format of "C" (for currency) it is applying this datafilter:
private void SetDataFilters(UltraGrid ugSender)
{
foreach (UltraGridBand ugBand in ugSender.DisplayLayout.Bands)
{
foreach (UltraGridColumn ugColumn in ugBand.Columns)
{
if (ugColumn.Format == "C" || ugColumn.Format == "c")
ugColumn.Editor.DataFilter = new GridCurrencyDataFilter();
}
}
}
Thats it. Even with it working like this (with the DataFilter returning null) it is noticably slower than without any datafilter. Am I setting this up wrong?
I managed to get the DataFilter thing working for grids, but from what I can tell, it seems to add a lot of overhead to drawing/formatting. So much that that it takes to scroll through records is two to four times as long.
Is this to be expected? Is this just the nature of DataFilters? Or am I doing something wrong?
I have done a little research, and read a bit about a DataFilter, which might be able to help. Is this the case, or am I just clutching at straws?
Thats not quite what I'm after. The formatting of my original message was all messed up (I'm blaming googles new browser for that), which probably made it difficult to see what I wanted.
If I use a MaskInput of "nn.nnnn", then it will display 12.3 as "12.3000" (in edit mode), whereas I want it to display as "12.30" (in edit mode). So I guess the rules of what I want to display (while in edit mode) are:
1) Display a minimum of 2 characters.
2) If value has more than 2 decimal places (say, 12.345), display the minimum number of decimal places to see the value in perfect accuracy (no trailing zeros).
3) Allow the user to add additional decimal places (change 12.345 to 12.3456).
Changing the MaskInput to "nn.nnnnn" does not quite do this. It will display that number of decimal places every time (in this case, 5), and not all the user to put a sixth in. So 12.345 will display as 12.34500, and will error if the user tries to change it to 12.345678.
Thanks. Your right – it was to do with how I was doing the threading. This seemed a bit weird, as it wasnt crashing imediatly – it was letting me update the bindingsource/grid a few times, and then crash on the 5th attempt. Weird.
But yes – nothing to do with Infragistics. Thanks for your help.