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
845
Automatically add character to editing cell, but dont fire Cell Update
posted

Hi there,

I have this scenario: Client can define many sub-packs in Grid A, each being identified with a letter (sub code)

In grid B, client can build packs based on sub-packs, and in any combination.

The pack code must be constructed using the sub pack codes concatenated with a plus sign (+) e.g.

A

A+B

A+B+C

B+C+D

I would like the + sign to be automatic i.e. the user must type AB to get A+B, and BCD to get B+C+D, however duplicates are not allowed. I would like the + sign to be added without firing the cell update events, where the duplicates are tested.

Can this be accomplished? I have had no luck - Text property is read-only and cannot be set, and setting Value property fires Update.

Thanks

Deon

Parents
  • 2575
    Verified Answer
    Offline posted

    Hello Deon,

    Please take a look at the UltraGridCell.EditorResolved. By setting the EditorResolved.Textbox.Text you will not fire Update(). The following snippet demonstrates inserting "+" into the Editor's text:

    private void UltraGrid1_KeyUp(object sender, KeyEventArgs e)
            {
                if (ultraGrid1.ActiveCell.IsInEditMode)
                {
                    EditorWithText editor = (EditorWithText)ultraGrid1.ActiveCell.EditorResolved;
                    string text = editor.CurrentEditText;
                    if (text.Length > 1)
                    {
                        for (int i = 1; i < text.Length; i += 2)
                        {
                            if (text[i] != '+')
                            {
                                text = text.Insert(i, "+");
                            }
                        }
                        editor.TextBox.Text = text;
                        editor.SelectionStart = text.Length;
                    }
                }
            }

    Please let me know how I can be of further assistance.

Reply Children
No Data