This is a migrated thread and some comments may be shown as answers.

Enable selection in readonly textbox grid cell

1 Answer 335 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mydatafactory
Top achievements
Rank 1
Mydatafactory asked on 14 Nov 2016, 09:51 AM
Is there a way to enable selection in a readonly textbox grid cell? So a user cannot edit the text but can select part of the text?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Nov 2016, 10:20 AM
Hello Jeroen,

Thank you for writing.  

Read-only columns are not supposed to enter edit mode. However, note that you can set the ReadOnly property of the column to false, but make the editor read-only. Thus, you will be allowed to enter edit mode and select part of the text. Here is a sample code snippet: 
public RadForm1()
{
    InitializeComponent();
     
    this.radGridView1.Columns["ProductName"].ReadOnly = false;
    this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
}
 
private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
    RadTextBoxEditor tb = e.ActiveEditor as RadTextBoxEditor;
    if (tb != null && this.radGridView1.CurrentColumn.Name == "ProductName")
    {
        RadTextBoxEditorElement el = tb.EditorElement as RadTextBoxEditorElement;
        el.TextBoxItem.ReadOnly = true;
    }
}

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Tags
GridView
Asked by
Mydatafactory
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or