-1

I have designed a grid control with 20 rows and 3 columns. In first column I have puted some hardcoded string and in second column I want to put checkBox with checked unchecked behavior so that user can modify it.I have written code for this in QueryCellInfo event in my below code but it is not working.

How do I complete it?

Kindly suggest.

Below is My Part of code:

public partial class Form1 : Form
{
    System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
    private Syncfusion.Windows.Forms.Grid.GridControl gridControlDownloadScript = new Syncfusion.Windows.Forms.Grid.GridControl();
    public Form1()
    {
       // this.gridControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
        InitializeComponent();

    }

    private void Form1_Load(object sender, EventArgs e)
    {

        gridControl1.Model.RowCount = 20;
        gridControl1.Model.ColCount = 3;
        this.gridControl1.VScrollPixel = true;
        this.gridControl1.HScrollPixel = true;


        this.gridControl1[0, 1].Text = "EMPLOYEE";
        this.gridControl1[0, 2].Text = "CHECKBOX";
        this.gridControl1[0, 3].Text = " ";
        this.gridControl1[1, 1].Text = "Rahul Verma";
        this.gridControl1[2, 1].Text = "MAnish Desai";
        this.gridControl1[3, 1].Text = "Mohan Pothala";
        this.gridControl1[4, 1].Text = "Dhanraj Dhoke";

        gridControl1.Model.RowCount = 20;

        gridControl1.Model.ColCount = 3;
        gridControl1.QueryCellInfo += new GridQueryCellInfoEventHandler(GridQueryCellInfo);
        gridControl1.SaveCellInfo += new GridSaveCellInfoEventHandler(GridSaveCellInfo);
        gridControl1.QueryRowCount += gridControl1_QueryRowCount;
        gridControl1.QueryColCount += gridControl1_QueryColCount;
        this.gridControl1.HScrollBehavior = GridScrollbarMode.Disabled; 
        this.gridControl1.VScrollBehavior = GridScrollbarMode.Disabled;

        this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cols(1, 1));

        this.gridControl1.RowHeights.ResizeToFit(GridRangeInfo.Rows(1, 20));


        t1.Interval = 250;

        t1.Tick += new EventHandler(IncreaseProgressBar);



    }

    private void CellClick(object sender, GridCellClickEventArgs e)
    {
    }



    private void IncreaseProgressBar(object sender, EventArgs e)
    {
        progressBar1.Increment(5);
        progressBar1.Minimum = 0;
        progressBar1.Maximum = 100;


        lblProgress.Text = progressBar1.Value.ToString() + "%";

        if (progressBar1.Value == progressBar1.Maximum)

            t1.Stop();
    }

    private void gridControl1_QueryColCount(object sender, GridRowColCountEventArgs e)
    {

    }

    private void gridControl1_QueryRowCount(object sender, GridRowColCountEventArgs e)
    {

    }

    private void GridQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
    {
        int i = 0;
        while (i++ < 4)
        {
            if (i == 0 || i == 1 || i == 4 || i == 6 || i == 9 || i == 11 || i == 14)
            {

                continue;

            }
            else if (e.RowIndex == i && e.ColIndex == 2)
            {

                e.Style.CellType = GridCellTypeName.CheckBox;

                e.Style.Description = "";
        this.gridControl1[i, 2].CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", string.Empty, false);
                e.Style.CheckBoxOptions.CheckedValue = "true";
                e.Style.CellValue = "true";

            }

        }
        if (e.RowIndex > 0 && e.ColIndex > 0)
        {


        }
    }
Ankit Raman
  • 79
  • 1
  • 14
  • What is the technology you use? Win forms? WPF? Also what do you mean by "On demand" you just want user to modify them right? – Emad Mar 16 '17 at 04:58
  • @Emad , I am using win forms.yes,I want user to modify them. Sorry for Confusion. – Ankit Raman Mar 16 '17 at 05:30

2 Answers2

0

You can manually do this using grid properties define column properties manually set column as checkbox then it will behave as you want

jadoon
  • 1
  • 2
0

The QueryCellInfo event will trigger for every cell in the GridControl. As per your code, you have set the cell value to true in the QueryCellInfo event. So the CellValue of CheckBox will remains True for all the time. If you want user to modify the CheckedValue set the CellValue for that particular cell as “True” in Form_Load() method. Please refer the below code, Code snippet this.gridControl1[2, 2].CellValue = "True"; this.gridControl1[3, 2].CellValue = "True";

Screenshot Sample Link

Note If you have any other queries regarding Syncfusion controls, please consider creating a support ticket or posting in the forums.

Prithiv
  • 504
  • 5
  • 20