GotFocus triggered twice when vaS1.EditModePermanent=true

Posted by: brosmi on 8 September 2017, 1:29 pm EST

  • Posted 8 September 2017, 1:29 pm EST

    I have a small test project with a textbox (Textbox1) and a DotNet SpreadControl (fpSpread1).

    I have the Enter event coded on the fpSpread1 to check if data not entered on Textbox1.

    When fpSpread1.EditModePermanent = true the event if triggered once

    but when it is false the event it is triggered twice.

    Can I prevent it being triggered twice ?






        public partial class Form1 : Form
            string sLast = "";

            public Form1()
                textBox1.Enter += Control_Enter;
                fpSpread1.Enter += Control_Enter;

            private void Form1_Load(object sender, EventArgs e)
                // IF I COMMENT OUT THIS LINE
                // THEN Error message only triggered once
                fpSpread1.EditModePermanent = true;

            private void Control_Enter(object sender, System.EventArgs e)
                if (((((Control)sender).Name) == "fpSpread1"))
                    if (textBox1.Text == "")
                        MessageBox.Show("PLEASE ENTER DATA IN TEXTBOX1");





  • Replied 8 September 2017, 1:29 pm EST

    Pat -

    I have no idea what you are doing here.  Do you have a small project you could attach showing this behavior.

  • Replied 8 September 2017, 1:29 pm EST

    I do not see a way to keep this from firing twice but I do not recommend going about things the way you are.  I would do the following...

    Private Sub FpSpread1_EnterCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EnterCellEventArgs) Handles FpSpread1.EnterCell
    If TextBox1.Text = "" Then


    End If

    End Sub

  • Replied 8 September 2017, 1:29 pm EST

    Hi Bob

    I am ok as the only reason I was using EditModePermanent was to hide the focus rectangle when a user leave the spread but I can just leave it there

    and set the size to 0.

    ((FpSpread)(eventSender)).FocusRenderer = new FarPoint.Win.Spread.SolidFocusIndicatorRenderer(Color.DarkSlateGray, 0);


    I always perform validation of cells using the enter event of each control to validate prior controls (i.e controls with a lower tabindex).

    I do this as I only want to validate in controls if user is going forward not backwards. 



Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels