Error calling BestFitColumns

36 posts, 0 answers
  1. Bradley Schultz
    Bradley Schultz avatar
    4 posts
    Member since:
    Jul 2006

    Posted 17 Dec 2010 Link to this post

    Since upgrading to Q3 SP1 I'm getting an error trying to use the BestFitColumns method on the GridView. What worked great on Q3 is now giving me an ArgumentOutOfRange exception.

    Error Message is "Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index"
    Stack trace is as follows:
       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at Telerik.WinControls.UI.StretchColumnLayoutHelper.ResizeColumn(Int32 delta)
       at Telerik.WinControls.UI.TableViewRowLayout.ResizeColumn(Int32 delta)
       at Telerik.WinControls.UI.TableViewRowLayout.StretchColumn(GridViewColumn column, Int32 desiredWidth)
       at Telerik.WinControls.UI.BestFitHelper.SetColumnWidth(GridViewColumn column, Single desiredWidth)
       at Telerik.WinControls.UI.BestFitHelper.BestFitColumnsCore()
       at Telerik.WinControls.UI.BestFitHelper.ProcessRequests()
       at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
       at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
       at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
       at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
       at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
       at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
       at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
       at Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(GridViewEvent gridEvent, Boolean postUI)
       at Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args)
       at Telerik.WinControls.UI.GridViewTemplate.FireViewChangedEvent(Object sender, DataViewChangedEventArgs args)
       at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
       at Telerik.WinControls.UI.GridViewTemplate.BestFitColumns()
       at HBS.Scanesthesia.WinForms.MainForm.SelectedPageChanged(Object sender, EventArgs e) in C:\Users\bschultz\Documents\Visual Studio 2010\Projects\Scanesthesia\HBS.Scanesthesia.Forms\MainForm.cs:line 267
       at HBS.Scanesthesia.WinForms.MainForm.ShownForm(Object sender, EventArgs e) in C:\Users\bschultz\Documents\Visual Studio 2010\Projects\Scanesthesia\HBS.Scanesthesia.Forms\MainForm.cs:line 48
       at System.Windows.Forms.Form.OnShown(EventArgs e)
       at System.Windows.Forms.Form.CallShownEvent()
       at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

    Any ideas? Has this changed some how from Q3 -> SP1?
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 17 Dec 2010 Link to this post

    Hello,

    I haven't been able to replicate your issue. Are you able to provide a small, simple exmaple of a grid view where I can replicate this to look into it for you?
    thanks
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 18 Dec 2010 Link to this post

    Same here.. my form won't load because of that too... for me it happens when I run Best fit Columns from the designer..  when my form tries to load and I get an error message saying the index was out of range, the same error I get when I run the Best fit columns from the designer..

    However, it happens only for one particular gridview. I deleted it, recreated it, attached the datasource, it worked fine until I clicked the best fit columns and here we go again, the grid is screwed..


    thanks
  5. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 18 Dec 2010 Link to this post

    it seems to happen when AutoSizeColumnsMode is set to Fill..
  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 19 Dec 2010 Link to this post

    Hi
    I still haven't been able to replicate this at the moment, but it sounds quite sporadic. I added a RadGridView, added some columns through the property builder, set the AutoSizeColumnMode to fill and then on the Smart Tag, hit BestFitColumns.

    regards,
    Richard
  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Dec 2010 Link to this post

    Hello guys,

    I've noticed this problem also, but only when inside a BeginUpdate() / EndUpdate(), if you are calling this from within, please try addin the BestFitColumns() after the EndUpdate().

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  8. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 19 Dec 2010 Link to this post

    Mine had a datasource with manually added columns.. when I changed the header text, hide some columns, etc. it happened..

    but like you said, it is very sporadic. I only have one problematic grid out of 200... but something is causing that for sure and deleting and recreating the grid does not help..

    thanks for trying
  9. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 19 Dec 2010 Link to this post

    To fix the issue during runtime, I had to set the autosizecolumnmode=true after calling the bestfitcolumns... calling it before caused the index out of range issue
  10. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Dec 2010 Link to this post

    Hello again,

    And you are calling the BestFitColumns in the DataBindingComplete event? And can you please tell me if you are using BeginUpdate() / EndUpdate() or DeferRefresh()?

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  11. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 19 Dec 2010 Link to this post

    Hi, no i'm calling the bestfitcolumn in the form's load event, after filling the datasource:

        Private Sub co_pnl_Payables_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Try
                RadGridLocalizationProvider.CurrentProvider = New Controls.FrenchRadControls.RadGridView
                ChargerPayables()  'I load the dataset here

                SetInitialFilters(dgPayable)
                dgPayable.BestFitColumns()
                dgPayable.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill

                LoadLayout(Me.Name + "." + dgPayable.Name, dgPayable, CalculMenuStrip)
            Catch ex As Exception

            End Try
        End Sub

    Like I said, the problem also occur when you click BestFitColumn in the designer.. only when AutoSizeColumnMode=Fill

    Thanks guys

  12. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Dec 2010 Link to this post

    Hello again,

    Please don't do that, please register for the DataBindingComplete event before setting the datasource, and fire the BestFitColumns() in the DataBindingComplete event and let me know if this solved your problem

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  13. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 19 Dec 2010 Link to this post

    I could, but I didn't experience that before SP1.. also what must I do in the designer?


    I will try and let you know
  14. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 19 Dec 2010 Link to this post

    Okay here are the results of my test.

    If I set the autosizecolumnmode to None, then there's no problem with the BestFitColumn in the DataBindingComplete. However, if I set the autosizecolumnmode to Fill, I cannot even load the form, I get the error message when I fire the form.show event.

    More details to come if needed, I got to go.

    thanks
  15. Bradley Schultz
    Bradley Schultz avatar
    4 posts
    Member since:
    Jul 2006

    Posted 19 Dec 2010 Link to this post

    I get the same result. Further information, even though there is no error is AutoSize is set to None, it does not do the best fit either...
  16. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 19 Dec 2010 Link to this post

    Bradley, can you try something, I also found that I cannot group by a column, only for the problematic grid. I cannot also hide/show columns...

    Worst, I copied and pasted the grid on top of the problematic one (so it should react the same way...) and I was able to group by column, but still can't hide/show. Another weird behaviour, when I right-click on the newly created grid using my custom contextmenu, it shows it no problem but once I clicked on an item, it shows another contextmenu that is not even in the form... wow.

    I don't know what else to check..
  17. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 20 Dec 2010 Link to this post

    Hello Marc-Andre,

    The reason I suspect you are getting the more than one action after clicking on your context menu is that you are manually adding event handlers in the ContextMenuOpening event for your click event. Each time you open the context menu you are creating the event handler on top of the one that already exists and therefore the click event is firing +1 times each time you open the context menu.
    Either remove the handler before adding it, or move this code out of the ContextMenuOpening event
    Regards,
    Richard
  18. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 20 Dec 2010 Link to this post

    Hello guys,

    Ok, can someone please post a full example so we can find a solution to this problem? Like i said the only problems I've been experiencing is that with the BestFitColumns() inside BeginUpdate / EndUpdate.

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  19. Bradley Schultz
    Bradley Schultz avatar
    4 posts
    Member since:
    Jul 2006

    Posted 20 Dec 2010 Link to this post

    Did some more troubleshooting and it seems like this is occurring when both the MinWidth and the MaxWidth for a column are set to the same values.

    On a side note, above mentions running BestFitColumns on DataBindingComplete. Is this just a best practice or a requirement(not in docuemtation). Also talks about calling on the MasterTemplate vs on the grid. Please clarify when BestFitColumns can be used.

    b  r  a  d
  20. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 20 Dec 2010 Link to this post

    Brad, thanks for pointing this one out, I also have a column with the same minWidth and maxWidth..

    I will do some tests on my end and let you know
  21. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 20 Dec 2010 Link to this post

    Changed the minWidth and I still have the same issue...

    Emmanuel, personnaly I cannot provide a full exemple my project is way too big and complex.. I will try to find something else..
  22. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 20 Dec 2010 Link to this post

    Whatever test I try, the grid must have the property AutoSizeColumnMode=None in order to use BestFitColumns...

    I can then call the AutoSizeColumnMode and set it to Fill, but most of the times I get various undesired behaviour.. (grid not being refreshed after grouping, filter row not working, BestFitColumns either give an error message index out of bound or the column width are badly calculted, etc.)

    That being said, since it seems to happend on all my grids now, I will try to create a small project and send it to you all later today...

    thanks
  23. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 21 Dec 2010 Link to this post

    Hi,

    Just to contribute, this is the first time I've also experienced now an issue with BestFit. Here is my stack trace.

    Object reference not set to an instance of an object.
      
       at Telerik.WinControls.UI.StretchColumnLayoutHelper.StartColumnResize(GridViewColumn column)
       at Telerik.WinControls.UI.TableViewRowLayout.StartColumnResize(GridViewColumn column)
       at Telerik.WinControls.UI.TableViewRowLayout.StretchColumn(GridViewColumn column, Int32 desiredWidth)
       at Telerik.WinControls.UI.BestFitHelper.SetColumnWidth(GridViewColumn column, Single desiredWidth)
       at Telerik.WinControls.UI.BestFitHelper.BestFitColumnsCore()
       at Telerik.WinControls.UI.BestFitHelper.ProcessRequests()
       at Telerik.WinControls.UI.RowsContainerElement.MeasureOverride(SizeF availableSize)
       at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
       at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
       at Telerik.WinControls.UI.ScrollViewElement`1.MeasureView(SizeF availableSize)
       at Telerik.WinControls.UI.ScrollViewElement`1.MeasureOverride(SizeF availableSize)
       at Telerik.WinControls.UI.GridTableElement.MeasureOverride(SizeF availableSize)
       at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
       at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
       at Telerik.WinControls.Layouts.DockLayoutPanel.MeasureOverride(SizeF constraint)
       at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
       at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
       at Telerik.WinControls.UI.LightVisualElement.MeasureElements(SizeF availableSize, SizeF clientSize, Padding borderThickness)
       at Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
       at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
       at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
       at Telerik.WinControls.RootRadElement.MeasureOverride(SizeF availableSize)
       at Telerik.WinControls.RootRadElement.MeasureCore(SizeF availableSize)
       at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
       at Telerik.WinControls.ComponentLayoutElementTree.PerformInnerLayout(Boolean performMeasure, Int32 x, Int32 y, Int32 width, Int32 height)
       at Telerik.WinControls.RadControl.GetInitialDesiredSize(Size availableSize, Boolean useNewLayoutSystem)
       at Telerik.WinControls.RadControl.OnLoad(Size desiredSize)
       at Telerik.WinControls.RadControl.LoadElementTree(Size desiredSize)
       at Telerik.WinControls.RadControl.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at Telerik.WinControls.UI.RadPageViewPage.set_Visible(Boolean value)
       at Telerik.WinControls.UI.RadPageViewElement.SetSelectedContent(RadPageViewItem item)
       at Telerik.WinControls.UI.RadPageViewElement.SetSelectedItem(RadPageViewItem item)
       at Telerik.WinControls.UI.RadPageViewElement.OnSelectedPageChanged(RadPageViewEventArgs e)
       at Telerik.WinControls.UI.RadPageView.SetSelectedPage(RadPageViewEventArgs e)
       at Telerik.WinControls.UI.RadPageView.set_SelectedPage(RadPageViewPage value)
       at Telerik.WinControls.UI.RadPageViewElement.SelectItem(RadPageViewItem item)
       at Telerik.WinControls.UI.RadPageViewElement.OnItemMouseDown(RadPageViewItem sender, MouseEventArgs e)
       at Telerik.WinControls.UI.RadPageViewStripElement.OnItemMouseDown(RadPageViewItem sender, MouseEventArgs e)
       at Telerik.WinControls.UI.RadPageViewItem.OnMouseDown(MouseEventArgs e)
       at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)
       at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadItem.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.DoMouseDown(MouseEventArgs e)
       at Telerik.WinControls.ComponentInputBehavior.OnMouseDown(MouseEventArgs e)
       at Telerik.WinControls.RadControl.OnMouseDown(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at Telerik.WinControls.RadControl.WndProc(Message& m)
       at Telerik.WinControls.RadNCEnabledControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
     as you've said, this only happens in Fill mode. I'll also look into this as we've never had this issue before.
    Richard
  24. Marc-Andre
    Marc-Andre avatar
    47 posts
    Member since:
    Jan 2009

    Posted 21 Dec 2010 Link to this post

    Great, I'm glad you found it! :)
  25. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 21 Dec 2010 Link to this post

    Hi All,

    Ok, in a new project I can replicate this every time now. The problem is a mixture of two things.
    In order to replicate this you need to have
    • AutoSizeColumnsMode set to Fill AND
    • Have at least one GroupDescriptor

    See the following code: Either change the code to remove the GroupDescriptor or, change to None for AutoSizeColumnsMode and BestFit works fine.
    (this is a RadGridView and a RadButton on a RadForm)

    Imports Telerik.WinControls.UI
    Imports System.ComponentModel
    Imports Telerik.WinControls.Data
      
    Public Class Form1
      
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      
            Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
            Me.RadGridView1.EnableGrouping = True
            Me.RadGridView1.ShowGroupPanel = False
      
            Dim people As New BindingList(Of Person)
            people.Add(New Person("Richard", 40, False))
            people.Add(New Person("Peter", 104, True))
            people.Add(New Person("Chris", 43, False))
            people.Add(New Person("Oliver", 12, False))
      
            Try
                Me.Cursor = Cursors.WaitCursor
                Me.RadGridView1.BeginUpdate()
                Me.RadGridView1.DataSource = Nothing
                Me.RadGridView1.DataSource = people
      
      
                Me.RadGridView1.GroupDescriptors.Clear()
                Dim descriptor As New GroupDescriptor()
                descriptor.GroupNames.Add("HasBeard", ListSortDirection.Ascending)
                Me.RadGridView1.GroupDescriptors.Add(descriptor)
      
                Me.RadGridView1.EndUpdate()
            Finally
                Me.Cursor = Cursors.Default
            End Try
      
        End Sub
      
        Private Sub RadButtonBestFit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButtonBestFit.Click
            Me.RadGridView1.BestFitColumns()
        End Sub
    End Class
      
    Public Class Person
      
        Public Sub New(ByVal name As String, ByVal age As Integer, ByVal hasBeard As Boolean)
            Me.Name = name
            Me.Age = age
            Me.HasBeard = hasBeard
        End Sub
      
        Public Property Name As String
        Public Property Age As Integer
        Public Property HasBeard As Boolean
      
    End Class

    Richard
  26. Svett
    Admin
    Svett avatar
    728 posts

    Posted 22 Dec 2010 Link to this post

    Hello Guys,

    @Richard: Thank you for your help in the forums.

    @Marc-Andre: I did not manage to reproduce the issue with Richard's code snippet. I tried to experience it with Q3 2010 (2010.3 10.1109) and Q3 2010 SP1 (2010.3 10.1215). I would kindly ask you to open a support ticket with an attached project where the issue can be reproduced. This will allow us to investigate the case further.

    Greetings,
    Svett
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  27. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 22 Dec 2010 Link to this post

    Hi Svett,

    I can send this on now as I have the project ready. I'll open a support ticket and include a video too.
    Hope this helps
    Richard
  28. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 22 Dec 2010 Link to this post

    Ticket opened with Id 378694
    and video with the ticket is here
    Richard
  29. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 23 Dec 2010 Link to this post

    Hi Guys,

    Just to let you know I've had a note that this is an issue that will be fixed in one of the upcoming releases. I understand that a workaround will be posted shortly.
    Regards,
    Richard
  30. Svett
    Admin
    Svett avatar
    728 posts

    Posted 27 Dec 2010 Link to this post

    Hello Guys,

    @Richard: Thank you for opening the support ticket.

    @Bradley Schultz: You can use the following code snippet to work around this issue. The issue will be addressed in our next major release.

    VB Version:

    Public Class MyTableViewRowLayout
        Inherits TableViewRowLayout
        Public Overrides Sub StartColumnResize(ByVal column As GridViewColumn)
            If column.IsGrouped AndAlso (Not column.OwnerTemplate.ShowGroupedColumns) Then
                Return
            End If
     
            MyBase.StartColumnResize(column)
        End Sub
    End Class
     
    Public Class MyTableViewDefinition
        Inherits TableViewDefinition
        Public Overrides Function CreateRowLayout() As IGridRowLayout
            Return New MyTableViewRowLayout()
        End Function
     
    End Class

    Me.RadGridView1.ViewDefinition = New MyTableViewDefinition()
    Dim rowLayout As New MyTableViewRowLayout()
    rowLayout.Initialize(Me.RadGridView1.TableElement)
    Me.RadGridView1.TableElement.ViewElement.RowLayout = rowLayout

    C# Version:

    public class MyTableViewRowLayout : TableViewRowLayout
    {
        public override void StartColumnResize(GridViewColumn column)
        {
            if (column.IsGrouped && !column.OwnerTemplate.ShowGroupedColumns)
            {
                return;
            }
     
            base.StartColumnResize(column);
        }
    }
     
    public class MyTableViewDefinition : TableViewDefinition
    {
        public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
        {
            return base.CreateViewUIElement(viewInfo);
        }
        public override System.Type RowLayoutType
        {
            get
            {
                return typeof(MyTableViewRowLayout);
            }
        }
        public override IGridRowLayout CreateRowLayout()
        {
            return new MyTableViewRowLayout();
        }
    }

    this.radGridView1.ViewDefinition = new MyTableViewDefinition();
    MyTableViewRowLayout rowLayout = new MyTableViewRowLayout();
    rowLayout.Initialize(this.radGridView1.TableElement);
    this.radGridView1.TableElement.ViewElement.RowLayout = rowLayout;

    I hope this helps.

    Regards,
    Svett
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  31. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 04 Jan 2011 Link to this post

    Hi All,

    Just an extra note so you can track this issue in PITS. the link is here
    All the best
    Richard
Back to Top
UI for WinForms is Visual Studio 2017 Ready