I have a class which inherits a ultrawingrid I set some default properties in the constructor but when the grid is drawn on the form the grid does not keep the properties. Any ideas on whats happening. It appears when the control is first drawn its correct but a few seconds later it changes.
I included a scaled down verion of my class which demostrates mky issue.
John
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infragistics.Win.UltraWinGrid;
{
public class grid: UltraGrid
}
~grid()
Check if in the form constructor these values are changed. This constructor happens after the grid class constructor.
In my project, all the changes I set to the grid class, are being copied to the form constructor, so if I change something in the class grid, it won't effect on the controls I have been already dragged.
If the property I change belongs to the grid itself (like RightToLeft) and it can be overriden, I overrided it and wrote my new value in an attribute of DefaultValue, and changed the value in the constructor.
For other properties like those in the appearance or those that can't be overriden, I don't have a nice solution. Currently I have some functions that set some properties in the grid class. In the form I call the appropriate functions to set the properties. That's works fine but you can't see the changes in the designer, only by runtime.
If someone has a solution for that I'll be glad to know.
The grid designer loads a Preset file into the grid by deafult when you create a new grid on a form. So it could be the designer. I beleive you can go into the Presets tab of the grid designer and turn this off.
That's just what I was looking for!
DisplayLayout.Override.CellClickAction = CellClickAction.EditAndSelectText
in the custom control (that inherits UltraGrid), when I drag this custom control to a form, it copies this row to the form InitializeComponents method. If I decide to change it in the custom control afterwards, it won't effect the grid I dragged before.
Meanwhile, I created a method that do this row, and in every form constructor I called this method so I can change this in one place, but I have to remember to write it down in every form.
Hi John,
Clearing the Preset after it's applied will work. But you can't actually turn off the loading of the preset in code. The reason for this is that the preset is not applied by the grid code, it's the grid designer that does it when you put the grid onto the form.It's basically a setting on the machine, not the grid.
I suppose if you are deriving your own grid, you could create your own grid designer and assign it to your control, thus removing the grid designer from your control.
I found a solution that is working for me. After searching the forums I found how to clear the presets of my control.
In my constructor of my inherited class I call the following method:
Infragistics.Win.PresetSerializer.ClearPresets(this);
This clears the presets and allows me to set my own defaults.