Selecting the first row

Posted by: hpadmasola1 on 8 September 2017, 2:20 pm EST

  • Posted 8 September 2017, 2:20 pm EST


    I am loading the grid with data and I have the operationMode set to singleSelect. I want the first row to be selected when the form shows up. How Can i make the first row selected ? I tried the below code. It highlights the row but does not have a border around it. I still need to click on the grid so I can use the up down arrow keys to go thru the rows in the grid. I want to avoid the clicking of the grid.

    <FONT size=2>

    Spr.Sheets(0).ActiveRowIndex = 0

    Spr.Sheets(0).Models.Selection.SetSelection(0, -1, 1, -1)

    </FONT> Any help is appreciated.


  • Replied 8 September 2017, 2:20 pm EST

    Hello Harish, 

    You would need to set the border for the selection of cells during SelectionChanging and SelectionChanged event.It seems that you want a complete row to be selected on moving focus using the arrow keys.You may use the following code to achieve the same:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            FpSpread1.ActiveSheet.SelectionUnit = FarPoint.Win.Spread.Model.SelectionUnit.Row

            FpSpread1.ActiveSheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.Single

            FpSpread1.Sheets(0).ActiveRowIndex = 0

            FpSpread1.Sheets(0).Models.Selection.SetSelection(0, -1, 1, -1)

        End Sub

        Private Sub FpSpread1_SelectionChanged(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.SelectionChangedEventArgs) Handles FpSpread1.SelectionChanged

            Dim lineBorder As New FarPoint.Win.LineBorder(Color.Black,2)

            FpSpread1.ActiveSheet.SetOutlineBorder(e.Range, lineBorder)

        End Sub

        Private Sub FpSpread1_SelectionChanging(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.SelectionChangingEventArgs) Handles FpSpread1.SelectionChanging

            Dim lineBorder As New FarPoint.Win.LineBorder(Color.Black, 0)

            FpSpread1.ActiveSheet.SetOutlineBorder(e.Range, lineBorder)

        End Sub

    I hope it will help you.




Need extra support?

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

Learn More

Forum Channels