Note that there are some explanatory texts on larger screens.

plurals
  1. POChange Display index of gridview column
    text
    copied!<p>we are using Telerik version = 2012.2.725.1050</p> <p>Here i am face one gridview problem while change DisplayIndex of gridview column </p> <p>Click on column, after when click on Left button focus and colum is moved perfectly but when we click on Right button colum is moved but focus is not moved focus must be moved. here i am add my sample project code </p> <p>thanks in advance for your help </p> <p><img src="https://i.stack.imgur.com/BBRAe.png" alt="enter image description here"></p> <pre><code>&lt;UserControl x:Class="GridTest.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:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"&gt; &lt;Grid x:Name="LayoutRoot" Background="White"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="50" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;telerik:RadGridView HorizontalAlignment="Left" x:Name="grdFormList" VerticalAlignment="Top" Grid.Column="0" Grid.Row="0" /&gt; &lt;StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1"&gt; &lt;Button Content="Left" Height="23" HorizontalAlignment="Left" Name="btnleft" Width="75" Margin="5,0,0,0" Click="btnleft_Click" /&gt; &lt;Button Content="Right" Height="23" HorizontalAlignment="Left" Name="btnright" Width="75" Margin="5,0,0,0" Click="btnright_Click" /&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; </code></pre> <p></p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Telerik.Windows.Controls; using Telerik.Windows.Controls.GridView; using Telerik.Windows; using System.ComponentModel; using System.Globalization; using System.Threading; namespace GridTest { public partial class MainPage : UserControl { public GridViewCellBase ClickedCell { get; set; } public MainPage() { InitializeComponent(); this.grdFormList.AddHandler(GridViewCellBase.MouseLeftButtonDownEvent, new MouseButtonEventHandler(MouseDownOnCell), true); grdFormList.Columns.Clear(); for (Int32 attributelength = 0; attributelength &lt; 10; attributelength++) { GridViewColumn textColumn = new GridViewColumn(); // DataGridTextColumn textColumn = new DataGridTextColumn(); textColumn.Header = string.Format("Column{0}", attributelength + 1); textColumn.UniqueName = string.Format("Uname{0}", attributelength + 1); textColumn.MinWidth = 5; textColumn.Width = 100; grdFormList.Columns.Add(textColumn); } } private void MouseDownOnCell(object sender, MouseEventArgs args) { if (((UIElement)args.OriginalSource).ParentOfType&lt;GridViewCellBase&gt;() != null) { var aa = ((GridViewHeaderRow)(((GridViewCellBase)((UIElement)args.OriginalSource).ParentOfType&lt;GridViewCellBase&gt;()).ParentOfType&lt;GridViewHeaderRow&gt;())).Cells; for (int i = 0; i &lt; aa.Count; i++) { ((GridViewCellBase)aa[i]).Background = new SolidColorBrush(Colors.Transparent); } this.ClickedCell = null; this.ClickedCell = (GridViewCellBase)((UIElement)args.OriginalSource).ParentOfType&lt;GridViewCellBase&gt;(); LinearGradientBrush brush = new LinearGradientBrush(); brush.StartPoint = new Point(0.5, 0); brush.EndPoint = new Point(0.5, 1); GradientStop g1 = new GradientStop(); g1.Color = Color.FromArgb(255, 227, 153, 54); brush.GradientStops.Add(g1); GradientStop g2 = new GradientStop(); g2.Color = Color.FromArgb(255, 254, 211, 125); brush.GradientStops.Add(g2); ((GridViewCellBase)((UIElement)args.OriginalSource).ParentOfType&lt;GridViewCellBase&gt;()).Background = brush; } } private void btnleft_Click(object sender, RoutedEventArgs e) { if (ClickedCell != null) { if (ClickedCell.Column != null) { int i = ClickedCell.Column.DisplayIndex; if (i &gt;= 1) { ClickedCell.Column.DisplayIndex = i - 1; } } } } private void btnright_Click(object sender, RoutedEventArgs e) { if (ClickedCell != null) { if (ClickedCell.Column != null) { int k = ClickedCell.Column.DisplayIndex; if (k &lt;= grdFormList.Columns.Count - 1) { ClickedCell.Column.DisplayIndex = k + 1; } } } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload