Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Cell Activation
posted

I am trying to take into account the activation of a cell to decide what my own code should do. However, I am having trouble because the actual activation of the cell can be affected by multiple different properties. In my debugging sessions, I notice a ActivationResolved property on the UltraGridCell that would likely be exactly what I need, but it appears to be an internal property.

My problem mainly stems from the fact that I cannot find a way to differentiate between a cell's actual Activation being AllowEdit or ActivateOnly. I am tempted to use reflection to access this property and be done with it, but I am assuming that there is a reason it has not been made public. Am I approaching this from the wrong angle?

To give more detail on what I'm doing, I'm working with the following legacy code:

                if(e.Cell.IsInEditMode == false) {
                    return;
                }

                //     <jp>日付Comboboxでデータがnullとき現在日で初期化</jp>
                //     <en>Initializing date and time when cell value is null.</en>
                if(e.Cell.Value.ToString().Length <= 0 &&
                    e.Cell.Column.DataType == System.Type.GetType("System.DateTime") &&
                    e.Cell.Column.CellActivation == Activation.AllowEdit) {
                    string fm = ((UltraGrid)sender).DisplayLayout.Bands[e.Cell.Band.Index].Columns[e.Cell.Column.Key].MaskInput.ToUpper();
                    if(fm.Length <= 10 && fm.IndexOf("HH") < 0) {
                        e.Cell.EditorResolved.Value = DateTime.Now.ToShortDateString();
                    } else {
                        e.Cell.EditorResolved.Value = DateTime.Now;
                    }
                }

In one particular case, the Row.Activation is being set to ActivateOnly, so the cell is being poplulated even though I would like it to remain null.

I have run into this issue before, and I remember writing my own logic (though I'd have to search to find it now), but I know that it is not equivalent to the logic in the ActivationResolved property, so there are probably cases where that code would also break...

Any help would be greatly appreciated. Thank you.

Parents Reply Children