Freezing Columns in 3 level Heirarchy

Posted by: himaheshh on 8 September 2017, 2:26 pm EST

  • Posted 8 September 2017, 2:26 pm EST


    if (fpSpreadRangeDecision.ActiveSheet != null)


    {


    if (!m_blnFreezeAppliied) //Freeze


    {


    if (fpSpreadRangeDecision.ActiveSheet.SelectionCount == 0)


    {


    MessageBox.Show("Atleast one column should be selected in Parent in order to freeze", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);


    return;


    }


    int intColumnIndex = fpSpreadRangeDecision.ActiveSheet.ActiveCell.Column.Index + 1;


    if (intColumnIndex > 4)


    {


    tsmFreezeColumn.Text = "Un&Freeze columns";


    fpSpreadRangeDecision.ActiveSheet.FrozenColumnCount = intColumnIndex;


    ArrayList alChildSht = fpSpreadRangeDecision.ActiveSheet.GetChildSheets();


    foreach (SheetView shtvwChild in alChildSht)


    {


    shtvwChild.FrozenColumnCount = intColumnIndex;


    ArrayList alGrandChildSht = shtvwChild.GetChildSheets();


    foreach (SheetView shtvwGrandChild in alGrandChildSht)


    {


    shtvwGrandChild.FrozenColumnCount = intColumnIndex;


    }


    }


    m_blnFreezeAppliied = !m_blnFreezeAppliied;


    m_intColFreezeCount = fpSpreadRangeDecision.ActiveSheet.FrozenColumnCount;


    }


     


    }


    else // Un freeze option...


    {


    if (fpSpreadRangeDecision.ActiveSheet.ActiveCell != null)


    {


    tsmFreezeColumn.Text = "&Freeze from selected column";


    m_intColFreezeCount = 4;


    fpSpreadRangeDecision.ActiveSheet.FrozenColumnCount = m_intColFreezeCount;


    ArrayList alChildSht = fpSpreadRangeDecision.ActiveSheet.GetChildSheets();


    foreach (SheetView shtvwChild in alChildSht)


    {


    shtvwChild.FrozenColumnCount = m_intColFreezeCount;


    ArrayList alGrandChildSht = shtvwChild.GetChildSheets();


    foreach (SheetView shtvwGrandChild in alGrandChildSht)


    {


    shtvwGrandChild.FrozenColumnCount = m_intColFreezeCount;


    }


    }


    }


     


    m_blnFreezeAppliied = !m_blnFreezeAppliied;


    }


    Using the above code, we are trying to enable the freezing of columns in a 3 level heirarchial view. Our requirement is to freeze the first 4 columns by default.  If the user wish to change, the user will select the column and apply the freezing. But that works only if the user selects  a column in the Parent level. If the User selects a column in  any of the Child , the code fpSpreadRangeDecision.ActiveSheet.ActiveCell.Column.Index  always returns a 0.


    Any help to get the selected column in the Child rows will be greatly appreciated.


    Thanks


    Mahesh

  • Replied 8 September 2017, 2:26 pm EST

    Mahesh,

    In order to get the selected column index in the Child rows you first need to query whether the parent view's cell has been clicked or the child view's cell in the CellClick event having e.View parameter passed in. It's
    the SpreadView object that contains the cell you clicked. You can then check it's Parent property. If the Parent
    property returns another SpreadView object, then the cell clicked on is a
    child SpreadView object; otherwise it is the parent.

    Hope this will help you. Thanks.

Need extra support?

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

Learn More

Forum Channels