How to Add CheckBox and manipulate in fixed header column using c1flexgrid

Posted by: ryoka0123 on 10 September 2017, 3:43 am EST

    • Post Options:
    • Link

    Posted 10 September 2017, 3:43 am EST

    Hi again,

    I have added a boolean value on my column.

    But how can i add it on Fixed header of a c1flexgrid and manipulate

    Example Scenario:

    A. If the checkbox is added on the fixed header and the value is true the corresponding value of all the column below the fixed header must be true and vice versa.

    B. If all the checkbox value is true, and the user suddenly uncheck one of the column that is not on the fixed header. The fixed header value checkbox will be false.

    Thank you.

  • Posted 10 September 2017, 3:43 am EST

    Hello,

    Please refer to the attached sample which clearly implements your both requirements.

    Firstly, in order to add checkbox in fixed cell, ‘SetCellCheck’ method of C1FlexGrid can be used.

    [csharp]c1FlexGrid1.SetCellCheck(0, 3, C1.Win.C1FlexGrid.CheckEnum.Checked);[/csharp]

    Futher click of checkbox(i.e. change in state) in a cell can be handled using ‘CellChecked’ event of C1FlexGrid.

    [csharp]void c1FlexGrid1_CellChecked(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)

    {

    if (e.Row == 0 && e.Col == 3)

    {

    ChangeState(c1FlexGrid1.GetCellCheck(e.Row, e.Col));

    }

    else

    {

    if (c1FlexGrid1.GetCellCheck(e.Row, e.Col) == C1.Win.C1FlexGrid.CheckEnum.Unchecked)

    c1FlexGrid1.SetCellCheck(0, 3, C1.Win.C1FlexGrid.CheckEnum.Unchecked);

    }

    }

    void ChangeState(C1.Win.C1FlexGrid.CheckEnum state)

    {

    for (int row = c1FlexGrid1.Rows.Fixed; row < c1FlexGrid1.Rows.Count; row++)

    {

    c1FlexGrid1.SetCellCheck(row, 3, state);

    }

    }[/csharp]

    Please refer to the attached video showing the same.

    Let me know if you face any problem.

    Cheers,

    Shubham Srivastava

    2015/06/CustomFixedHeader.zip

    2015/06/Fixed_CheckBox.gif

  • Posted 10 September 2017, 3:43 am EST

    Hi Shubham Srivastava,

    Thank you for your reply.

    Can you convert it to vb im having an error converting it to VB.net.

    Thank you so much.

  • Posted 10 September 2017, 3:43 am EST

    Hi,

    Please find the attached VB sample corresponding to previously attached C# Sample.

    Let me know if you face any problem in implementation.

    Best Regards,

    Shubham Srivastava

    2015/06/CustomFixedHeader_VB.zip

  • Posted 10 September 2017, 3:43 am EST

    Hi Shubham Srivastava,

    Thanks for your reply.

    It work as i have needed.

    However if i click/checked all the checkedbox the fixed header must be checked.

    Thanks again.

  • Posted 1 October 2020, 6:51 am EST

    Is possible to center the checkbox on cell?

  • Posted 4 October 2020, 4:14 pm EST

    Hi,

    You can set the position of Checkbox using the ImageAlign property of CellStyle.

    A sample is attached for reference, please have a look.

    Regards,

    Prabhat Sharma.

    HeaderCheckbox.zip

Need extra support?

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

Learn More

Forum Channels