Get the selection position and selection count of a text cell in EditMode?

Posted by: jhoover on 8 September 2017, 1:37 pm EST

  • Posted 8 September 2017, 1:37 pm EST

    During EditMode, I can read the entire contents of the active cell like this: mySpread.ActiveSheet.ActiveCell.Text


     Is there a way to find what where the selection point is and the number of characters selected?


     Thanks,


    Jeff

  • Replied 8 September 2017, 1:37 pm EST

    You can use the SelectionStart and SelectionLength properties.
  • Replied 8 September 2017, 1:37 pm EST

    <BLOCKQUOTE><div><img src="/wp-content/uploads/CS_images/icon-quote.gif"> BobM:</div><div>You can use the SelectionStart and SelectionLength properties.
    </div></BLOCKQUOTE>


     What are those a property of? I'm using 3.0.2005.2005 and FarPoint.Win.Spread.Cell doesn't have those properties.


     


    Thanks,


    Jeff

  • Replied 8 September 2017, 1:37 pm EST

    Jeff,


    They are properties of the editor of your cell. You can query the EditingControl property of the Spread when the Spread goes into editmode to get this.

  • Replied 8 September 2017, 1:37 pm EST

    <BLOCKQUOTE><div><img src="/wp-content/uploads/CS_images/icon-quote.gif"> scotts:</div><div>

    Jeff,


    They are properties of the editor of your cell. You can query the EditingControl property of the Spread when the Spread goes into editmode to get this.


    </div></BLOCKQUOTE>


     


    Could you give me a brief code example?

  • Replied 8 September 2017, 1:37 pm EST

    Jeff,


    Here is code to use the MouseUp event of the editor to find what was selected.

    <FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT size=2> FpSpread1_EditModeOn(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Object</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> System.EventArgs) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Handles</FONT></FONT><FONT size=2> FpSpread1.EditModeOn


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> c </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> FarPoint.Win.Spread.CellType.GeneralEditor


    c = FpSpread1.EditingControl


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>AddHandler</FONT></FONT><FONT size=2> c.MouseUp, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>AddressOf</FONT></FONT><FONT size=2> mymouseup


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Public</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT size=2> mymouseup(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Object</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> System.Windows.Forms.MouseEventArgs)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> c </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> FarPoint.Win.Spread.CellType.GeneralEditor = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>CType</FONT></FONT><FONT size=2>(sender, FarPoint.Win.Spread.CellType.GeneralEditor)


    Debug.WriteLine(c.SelectionStart & </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" --- "</FONT></FONT><FONT size=2> & c.SelectionLength)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub

    </FONT></FONT>
Need extra support?

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

Learn More

Forum Channels