Row Selection minus one column

Posted by: guiguy on 8 September 2017, 12:53 pm EST

  • Posted 8 September 2017, 12:53 pm EST

    I'm having trouble figuring out how I can use the multi-select row option and turn off the selection for just one column.  For that column I would likd to be able to select by cell.  I'm working in C#. 


    Steven

  • Replied 8 September 2017, 12:53 pm EST

    Not sure I understand what you're asking.  The row header will be included in the selection.
  • Replied 8 September 2017, 12:53 pm EST

    What about with a rowheader?  Does that make any difference?


    Steven

  • Replied 8 September 2017, 12:53 pm EST

    O.K. Thanks for the info.


    Steven

  • Replied 8 September 2017, 12:53 pm EST

    It can't be done.  There is not a way to set the OperationMode to multiselect and then take a column out of the mix.
  • Replied 8 September 2017, 12:53 pm EST

    Thanks Bob, that was the fix.  Now I have another question related to selecting cells based on the CellClick event that you mentioned earlier.  In the CellClick event handler I added the following code to select all the cells in a row minus the first one.


    int index = fpSpread1.ActiveSheet.Rows[e.Row].Index;


    fpSpread1.ActiveSheet.AddSelection(index, 1, 1, 4);


    As you can imagine it doesn't appear to be working, thus my post.


    Steven

  • Replied 8 September 2017, 12:53 pm EST

    One thing you could try is leaving the OperationMode at normal and in the CellClick event add a selection based on the row and leave the the first column out of the selection.  You would have to lock the spreadsheet to get the same behavior as MultiSelect.
  • Replied 8 September 2017, 12:53 pm EST

    Bob what exactly did you mean by lock the spreadsheet?  I'm having trouble finding that info.


    Steven

  • Replied 8 September 2017, 12:53 pm EST

    Steven -

    Let me play around with this.  It's not working like I expected it would.  I will let you know if I can find a way to make it work.
  • Replied 8 September 2017, 12:53 pm EST

    The code you gave me for locking doesn't seem to work.  I keep getting the error message "FarPoint.Win.Spread.SheetView.Rows is a property but is used like a method."  I can't seem to figure out how to reconfigure the statement to get it to work.  I'm working in C# and I translated it to fpSpread1.ActiveSheet.Rows(e.Row).Locked = true;


    Steven

  • Replied 8 September 2017, 12:53 pm EST

    Steven -

    C# handles indices differently...

    fpSpread1.ActiveSheet.Rows[e.Row].Locked = true;
  • Replied 8 September 2017, 12:53 pm EST

    Steven -

    When you use the MultiSelect operation mode you can't make changes to any of the cells in the rows.  If you want to mimic that then you would do the following...

    FpSpread1.ActiveSheet.Rows(e.Row).Locked = True

  • Replied 8 September 2017, 12:53 pm EST

    Steven -

    Here is the code for the selection...

    private void fpSpread1_CellClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e)
    {
    e.Cancel=true;
    e.View.Sheets[0].AddSelection(e.Row,1,1,fpSpread1.ActiveSheet.ColumnCount);

    }
    private void Form1_Load(object sender, EventArgs e)
    {

    fpSpread1.ActiveSheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.Range;
    fpSpread1.ActiveSheet.SelectionUnit = FarPoint.Win.Spread.Model.SelectionUnit.Cell;

    }
  • Replied 8 September 2017, 12:53 pm EST

    That should be doable.
  • Replied 8 September 2017, 12:53 pm EST

    I just wanted to take this discussion in a different direction because it occurred to me that perhaps there is an easier way to accomplish what I'm trying to do. What I am trying to do is to create a databound grid that will allow selection of rows in a multi-select fashion.  However the twist is that I need to have a rowheader "type" column that can be selected that would "pin" the selected row to the grid to prevent clearing.  To date I have been trying to do this with a single spread control.  Would I be able to implement this type of functionality with 2 spread controls?  The main control would be a multi-select row grid with no visible rowheader and the other control would be a single column that would be cell selectable independent of the other grid.  Clearing the contents of the main grid would be dependent upon the selection in the single column grid.  What do you think?


    Steven

Need extra support?

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

Learn More

Forum Channels