Cell Read Only

13 posts, 0 answers
  1. Erik
    Erik avatar
    80 posts
    Member since:
    Jul 2007

    Posted 02 Aug 2007 Link to this post

    Is it possible to make the individual cell read only?
    Thanks
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 03 Aug 2007 Link to this post

    Hello eriksurya,

    We are still working on the grid API. Up to the moment such functionality. We can suggest a workaround:

    protected override OnLoad(EventArgs e)   
        base.OnLoad(e); 
        radGridView1.CurrentCellChanged +=new Telerik.WinControls.UI.CurrentCellChangedEventHandler(radGridView1_CurrentCellChanged); 
     
    private void radGridView1_CurrentCellChanged(object sender, Telerik.WinControls.UI.CurrentCellChangedEventArgs e) 
        if ((int)radGridView1.CurrentCell.Value == 3) 
            radGridView1.CurrentCell.ColumnInfo.ReadOnly = true
        else 
            radGridView1.CurrentCell.ColumnInfo.ReadOnly = false

    I hope that will help you continue with your project. In the future releases we will provide better ways to prevent cells from editing.

    If you have other troubles, we will be glad to help you.

    Regards,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. kilhoffer
    kilhoffer avatar
    40 posts
    Member since:
    May 2007

    Posted 22 Jul 2008 Link to this post

    Is there a way to make a row readonly? I need certain rows to be readonly based on the content of one of the cells.

    Thanks...
  5. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 23 Jul 2008 Link to this post

    Hi Anthony,

    Thank you for contacting us.

    I suggest you process the CellBeginEdit event. Consider the code snippet below:

    void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) 
        if ((int)this.radGridView1.CurrentRow.Cells[2].Value == 3) 
        { 
            e.Cancel = true
        } 


    I hope this helps. Do not hesitate to write me if you have other questions.

    Kind regards,
    Jack
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. ertan
    ertan avatar
    1 posts
    Member since:
    Sep 2008

    Posted 24 Mar 2009 Link to this post

    Was this problem resolved ?
    My telerik version is "2009.1.9.311".
  7. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 24 Mar 2009 Link to this post

    Hello ertan,

    This is not a problem. The best practice is to process the CellBeginEdit event to prevent a cell from being changed, as described in the previous post.
     
     
    Kind regards,
    Jack
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  8. Zensell
    Zensell avatar
    12 posts
    Member since:
    Jul 2009

    Posted 11 Aug 2009 Link to this post

    It's working fine with Q1 2009 SP1 but it is not working with Q2 2009 SP1 for GridViewCheckBoxColumns. Is there a workaround for this?
  9. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 11 Aug 2009 Link to this post

    Hello Zensell Zensell,

    Yes, you should handle ValueChanging event in this case. Please consider the code snippet below:

    void radGridView1_ValueChanging(object sender, ValueChangingEventArgs e) 
        if (sender is RadCheckBoxEditor) 
        { 
            e.Cancel = true
        } 

    We will address the issue in our next release. Should you have any other questions, don't hesitate to contact us.

    Greetings,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 28 Sep 2009 Link to this post

    so from what I understand there's no way to set a single cell read-only? In my application, some cell within the column can or cannot be edited depending on the product type so I cannot set the entire column read-only. Also I need to know if the cell is read-only in order to make extra calculation.

    Is there a way to accomplish this with 2009.2.9.729?

    Thanks
  11. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 29 Sep 2009 Link to this post

    Hi Marc-Andre,

    You can make a single cell read-only by handling CellBeginEdit event. Here is a sample:

    void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) 
        if (((GridViewDataColumn)this.radGridView1.CurrentColumn).UniqueName == "Value" && 
            (int)this.radGridView1.CurrentRow.Cells[0].Value > 10) 
        { 
            e.Cancel = true
        } 

    However, there is no way to use the read-only state of the cell for calculations. You can use the cell values instead.

    Greetings,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  12. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 29 Sep 2009 Link to this post

    Thanks for the reply, if you read my post I can't simply use what you mention because I need to know if a cell is currently read-only or not. Using the BeginEdit would only cancel any data sent from the user. Since you can set the column property to read-only, I do not see the point of using the BeginEdit event to prevent the user from modifying the value in the cell.

    Is there another way?
  13. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 30 Sep 2009 Link to this post

    Hello Marc-Andre,

    Maybe I did not understand your question correctly. GridViewColumn.ReadOnly property makes entire column read-only. However, when you want to make a single cell read-only, you have to use CellBeginEdit event. There is no read-only property for grid cells. I assume that the read-only state of the cell depends on some condition. If so, you can calculate this condition when needed (e.g when processing CellBeginEdit event).

    If this doesn't help, please describe the desired behavior in detail and I will be glad to assist you further. I am looking forward to your reply.

    Sincerely yours,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  14. lucerias
    lucerias avatar
    16 posts
    Member since:
    Nov 2011

    Posted 09 Nov 2011 Link to this post

    I want to make a single cell readonly = false so that it can be edited.
    What i want to achieve is something like this. I have three columns, first is CustomerID, second is CustomerAddress, last is Checkbox.

    All columns are in readonly.
    Whatever user tick on the checkbox, customeraddress must be editable.

    I have got the row already but not able to set CustomerAddress to be editable.

    My xaml code is shown as below. SilverLight version is 4.

    <telerik:GridViewDataColumn Header="Customer address" DataMemberBinding="{Binding CustomerAddress, Mode=TwoWay}" IsReadOnly="True" >
        <telerik:GridViewDataColumn.CellTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding CustomerAddress}" />
            </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>
      
        <telerik:GridViewDataColumn.CellEditTemplate>
            <DataTemplate>
                <TextBox Text="{Binding CustomerAddress, Mode=TwoWay}"  />
            </DataTemplate>
        </telerik:GridViewDataColumn.CellEditTemplate>
    </telerik:GridViewDataColumn>


    My behind code is shown as below.

    CheckBox chk = (CheckBox)sender; 
    GridViewRow row = chk.ParentOfType<GridViewRow>();
      
    row.Cells[1].IsReadOnly = False not supported.


    I stuck at this for few days already. I have achieved using TextBox instead of TextBlock but the look and feel just not right.
    Hence i want it to be displayed in TextBlock and edit in TextBox.

    Please let me know the alternative. Thank you very much.

Back to Top
UI for WinForms is Visual Studio 2017 Ready