Allow Row Moving for particular ROW in Spread Sheet.

Posted by: nabinpadhi on 8 September 2017, 12:27 pm EST

  • Posted 8 September 2017, 12:27 pm EST

    Hi, I am using Win Spread vs2.5 for VS.NET 2003


    I want to allow certain row to be AllowRowMove = true, how can i do this ?


    Example:


    I have a spreadsheet with 3 column and 3 row


    ------------------------------------------------------


    <FONT>Name            Company               IsTrialVersion</FONT>


    ----------------------------------------------------


    Nabin            WebSpark               No


    ---------------------------------------------------


    San                  XYZ                     Yes


    --------------------------------------------------


    Mark               YYY                     No


    -------------------------------------------------


     


    in above spread sheet i should able to move the rows where IsTrail = Yes and the row with IsTrail = No will be fixed.


    Please help me out.


     

  • Replied 8 September 2017, 12:27 pm EST

    There's not a real clean way to do this but you can do the following...

    Private Sub FpSpread1_CellClick(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.CellClickEventArgs) Handles FpSpread1.CellClick
    If e.RowHeader And e.Row = 1 Then
    FpSpread1.AllowRowMove = True
    Else
    FpSpread1.AllowRowMove = False
    'e.Cancel = True
    End If
    End Sub

    I'll let you decide if you want to use the e.Cancel parameter. 
  • Replied 8 September 2017, 12:27 pm EST

    Thats Great  Bob


    here is my modified code


    <FONT color=#0000ff><SPAN class=kwd>Private Sub</SPAN> FpSpread1_CellClick(<SPAN class=kwd>ByVal</SPAN> sender <SPAN class=kwd>As Object</SPAN>, <SPAN class=kwd>ByVal</SPAN> e <SPAN class=kwd>As</SPAN> FarPoint.Win.Spread.CellClickEventArgs) <SPAN class=kwd>Handles</SPAN> FpSpread1.CellClick
            <SPAN class=kwd>If</SPAN> e.RowHeader </FONT><FONT color=#0000ff><SPAN class=kwd>Then
                If</SPAN> FpSpread1.ActiveSheet.Cells(e.Row, 2).Value = <SPAN class=st>"No"</SPAN> <SPAN class=kwd>Then</SPAN>
                    FpSpread1.AllowRowMove = </FONT><FONT color=#0000ff><SPAN class=kwd>True
                Else</SPAN>
                    FpSpread1.AllowRowMove = </FONT><FONT color=#0000ff><SPAN class=kwd>False
                End If
            Else</SPAN>
                FpSpread1.AllowRowMove = </FONT><SPAN class=kwd><FONT color=#0000ff>False
            End If
    End Sub</FONT></SPAN>

     
  • Replied 8 September 2017, 12:27 pm EST

    Hello,


    You would need to cancel the RowDragMove event if you do not want a particular row to be moved.

     
      <SPAN class=kwd>Private Sub</SPAN> FpSpread1_RowDragMove(<SPAN class=kwd>ByVal</SPAN> sender <SPAN class=kwd>As Object</SPAN>, <SPAN class=kwd>ByVal</SPAN> e <SPAN class=kwd>As</SPAN> FarPoint.Win.Spread.DragMoveEventArgs) <SPAN class=kwd>Handles</SPAN> FpSpread1.RowDragMove
    <SPAN class=kwd>If</SPAN> e.Index = 3 <SPAN class=kwd>Then</SPAN> e.Cancel = <SPAN class=kwd>True
    End Sub</SPAN>
     
Need extra support?

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

Learn More

Forum Channels