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

[Solved] Determine grid in edit mode

1 Answer 142 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alan
Top achievements
Rank 2
Alan asked on 10 Jul 2009, 01:25 PM
Is there any way to programmatically determine if the grid is in edit mode?  Something like, myGrid.IsBeingEdited?  I don't see any property like this.  Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 13 Jul 2009, 03:48 PM
Hi Alan,

You can attach to these three events and raise / clear a flag:

using System.Windows.Controls; 
using Telerik.Windows.Controls; 
using Telerik.Windows.Data; 
 
namespace Ticket226810 
    public partial class Page : UserControl 
    { 
        bool isGridEditing = false
         
        public Page() 
        { 
            InitializeComponent(); 
 
            this.playersGrid.ItemsSource = Club.GetPlayers(); 
 
            this.playersGrid.BeginningEdit += new System.EventHandler<GridViewBeginningEditRoutedEventArgs>(playersGrid_BeginningEdit); 
            this.playersGrid.RowEditEnded += new System.EventHandler<GridViewRowEditEndedEventArgs>(playersGrid_RowEditEnded); 
            this.playersGrid.CellEditEnded += new System.EventHandler<GridViewCellEditEndedEventArgs>(playersGrid_CellEditEnded); 
        } 
 
        void playersGrid_BeginningEdit(object sender, GridViewBeginningEditRoutedEventArgs e) 
        { 
            this.isGridEditing = true
            this.isEditingTextBlock.Text = "EDITING..."
        } 
 
        void playersGrid_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) 
        { 
            this.isGridEditing = false
            this.isEditingTextBlock.Text = "NOT EDITING..."
        } 
         
        void playersGrid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e) 
        { 
            this.isGridEditing = false
            this.isEditingTextBlock.Text = "NOT EDITING..."
        } 
    } 
 

And the XAML:
<UserControl x:Class="Ticket226810.Page" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
               xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
             xmlns:local="clr-namespace:Ticket226810;assembly=Ticket226810"
    <Grid> 
      <Grid.RowDefinitions> 
        <RowDefinition Height="Auto"/> 
        <RowDefinition Height="Auto"/> 
      </Grid.RowDefinitions> 
      <TextBlock Name="isEditingTextBlock"  
                 Margin="10" 
                 Text="Here you will see whether the grid is editing or not..."/> 
      <local:MyGrid Name="playersGrid"  
                           Grid.Row="1"  
                           AutoGenerateColumns="False" 
                           ColumnsWidthMode="Auto"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}"
                </telerik:GridViewDataColumn> 
                <telerik:GridViewDataColumn Header="Number" DataMemberBinding="{Binding Number}"
                </telerik:GridViewDataColumn> 
                <telerik:GridViewDataColumn Header="Position" DataMemberBinding="{Binding Position}"
                </telerik:GridViewDataColumn> 
                <telerik:GridViewDataColumn Header="Country" DataMemberBinding="{Binding Country}"
                </telerik:GridViewDataColumn> 
            </telerik:RadGridView.Columns> 
        </local:MyGrid> 
    </Grid> 
</UserControl> 
 

I have attached the sample project that the above code snippet is from.

Please, let me know if you have any other questions or trouble with the sample project.

All the best,
Ross
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.
Tags
GridView
Asked by
Alan
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Share this question
or