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

about GridViewCell isEnable

3 Answers 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
sun
Top achievements
Rank 1
sun asked on 08 Jun 2011, 04:16 AM
Hi,
   I have a problem with GridViewCell property of isEnable.  I want to set some GridViewCell  the edition attribute  .   I use silverlight  controls  v2.0.50727 and version is 2011.1.315.1040.
   In my project, the code below:
 dataGrid1.RowLoaded += new EventHandler<RowLoadedEventArgs>(dataGrid1_RowLoaded);
 void dataGrid1_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            e.Row.Cells[0].IsEnabled = false;
        }

But when I  cilck (drag) the horizontalscrollViewer in the gridview,the other  Cells cannot be edited and Cells[0] can edit
. is it bug?. How to solve it. thanks!

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 08 Jun 2011, 07:08 AM
Hello sun,

Actually, it is not recommended to work with the visual elements and their values as due to the virtualization, they will be recycled and reused again. Thus, you may end up with getting/setting a particular value to an element that you do not want to. May  I ask you what is the exact scenario that you want to accomplish ? Wouldn't it be more appropriate to define a style for the cells in the fist column or use a CellStyleSelector ? Do you want just to make that cells read-only ?

Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
sun
Top achievements
Rank 1
answered on 09 Jun 2011, 05:24 AM
Thanks for you help!
Yes, i want just to make that cells read-only  but not same Column. 
For example , I want to set row[0].Cell[0].IsEnable to be false ,and  row[0].Cell[1].IsEnable to be true;
But when I  darg the horizontalscrollViewer in the gridview,row[0].Cell[0] can edit .

<UserControl x:Class="SerializationProject.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             >

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
     </Grid>
</UserControl>

void Serives_ResponseComplete()
        {

              RadGridView dataGrid1 = new RadGridView();
                dataGrid1.RowLoaded += new EventHandler<RowLoadedEventArgs>(dataGrid1_RowLoaded);
                this.dataGrid1.ItemsSource = dt.Rows;
                this.dataGrid1.SetValue(Grid.RowProperty, 1);
                this.LayoutRoot.Children.Add(dataGrid1);
        }

        void dataGrid1_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            e.Row.Cells[0].IsEnabled = false;
        }


I  have a picture for this
0
Dimitrina
Telerik team
answered on 09 Jun 2011, 03:58 PM
Hi sun,

 You may make the whole column ReadOnly, instead of setting every cell of this column to be not enabled. Like:

private void clubsGrid_Loaded(object sender, EventArgs e)
        {
            clubsGrid.Columns[0].IsReadOnly = true;
        }

If you would like to make the Readonly cells with different appearance, you may use CellStyleSelector.

Is this working for you? 


Greetings,
Didie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
sun
Top achievements
Rank 1
Answers by
Maya
Telerik team
sun
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or