C1.Win.C1TrueDBGrid.C1TrueDBGrid enter EditMode of a non edtiable column

Posted by: jens.eidinger on 11 February 2021, 6:54 pm EST

    • Post Options:
    • Link

    Posted 11 February 2021, 6:54 pm EST

    Hi,

    please see attached testcase.

    When you have a DataTable with ReadOnly columns and create the grid by yourseelf and use the HoldFields with true (SetDataBinding), then you can enter the EditMode of the ReadOnly columns and change the values. Fortunately, the Grid then throws an error dialog, but because my customer’s code is also executed in BeforeColUpdate event it comes to multiple errors.

    Addtional: When you set HoldFields to false, when calling SetDataBinding, or when you just assign the DataTable to DataSource property, then you can’t enter the EditMode of the ReadOnly cells.

    In my testcase, just try to bring the last column in EditMode (do a double click e.g.) and you will get the BeforeColEdit event and also the DatePicker Control is displayed. When you then select a new Date you will get a Error Message Dialog from the grid.

    EditANonEditableColumnTest.zip

    Best,

    Jens

  • Posted 11 February 2021, 6:57 pm EST - Updated 3 October 2022, 2:23 pm EST

    Here an image of the error message, which comes.

  • Posted 14 February 2021, 5:52 pm EST

    Hello Jens,

    When using the SetDataBinding method and setting the HoldFields parameter to true, it preserves the design-time layout and if the layout is not present, it preserves the column with default properties.

    You can verify it by the value of the Locked after setting the SetDataBinding method.

    Console.WriteLine(c1TrueDBGrid1.Splits[0].DisplayColumns[2].Locked);
    
    

    If the HoldFields parameter is false, then it preserves the layout as per the data schema and that is why the column is non-editable.

    If you use the HoldFields parameter as true, then you can use the BeforeColEdit event and set the Cancel property to true or set the Locked property of the column to true after loading the data.

    Regards,

    Prabhat Sharma.

Need extra support?

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

Learn More

Forum Channels