Extended Select

Posted by: parez81-fp on 8 September 2017, 1:08 pm EST

  • Posted 8 September 2017, 1:08 pm EST


    I am using extended select mode as the operation mode. My first column is a check box column.
    The header of that column is also check box.

    Right now if some one clicks on that header, all the check boxes get checked but not highlighted.

    how do i tie the selection of a row to the checkbox and vice versa.
    if  I have to do that manually then
    how do i handle the extended select? 


    TIA



  • Replied 8 September 2017, 1:08 pm EST

    Also the selected/highlighted row must be unselected when we click it again..
    click event should toggle selection
  • Replied 8 September 2017, 1:08 pm EST

    Hello,


    It sounds like you want to use MultiSelect instead of ExtendedSelect to have the click of a row select or unselect the row. To check/uncheck a checkbox cell in the row, you would need to write code to catch the CellClick event to find the row being selected and programatically upadate the checkbox cell setting the Value of the cell to True/False.

  • Replied 8 September 2017, 1:08 pm EST

    Hi Scott,

    I want to use ExtendedSelect. I want to be able to drag the mouse and select rows. and as i drag the mouse i want to check the  checkboxes... also if some other rows get deselected then they have to be unchecked.
    What are the various events that i need to handle..


    For the header Check box problem..
     
     private void fpSpread1_CellClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e)
    {
     if (e.ColumnHeader && e.Column == 0 && !e.RowHeader)
                {
                    //clicked on the column header of the check box cell and not rowheader

                    if (fpSpread1_Sheet1.ColumnHeader.Cells[0, 0].Value.ToString().Trim()==string.Empty
                        || fpSpread1_Sheet1.ColumnHeader.Cells[0, 0].Value.ToString().Trim() == "0")                   
                    {
                        fpSpread1_Sheet1.ColumnHeader.Cells[0, 0].Value = 1;
                        SetRows(true);
                    }
                    else
                    {
                        fpSpread1_Sheet1.ColumnHeader.Cells[0, 0].Value = 0;
                        SetRows(false);
                    }

                }



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

     private void SetRows(bool selected)
            {
                for (int i = 0; i < fpSpread1_Sheet1.Rows.Count; i++)
                {
                    fpSpread1_Sheet1.Cells[i, 0].Value = selected; ;
                }

                if (selected)
                {
                    fpSpread1.ActiveSheet.AddSelection(0, fpSpread1.ActiveSheet.Columns.Count - 1, fpSpread1.ActiveSheet.Rows.Count = 1, fpSpread1.ActiveSheet.Columns.Count - 1);
                }
                else
                {
                    fpSpread1.Sheets[0].Models.Selection.ClearSelection();
                }


            }


    The above code reduces the grid to only one rows.(all 500 rows are blank)


  • Replied 8 September 2017, 1:08 pm EST

    You might try the selectionchanging.  The cellclick may not always work since the user can drag and select many rows at a time.

    Private Sub FpSpread1_SelectionChanging(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.SelectionChangingEventArgs) Handles FpSpread1.SelectionChanging
            ListBox1.Items.Add(e.Range.Row)
            ListBox1.Items.Add(e.Range.RowCount)
        End Sub
Need extra support?

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

Learn More

Forum Channels