How to lock width/height in column/row header in GcSpreadSheet

Posted by: sk.0911749090 on 6 June 2018, 3:13 am EST

  • Posted 6 June 2018, 3:13 am EST

    Hello, there is way how to lock and avoid the change by user of width/height of column/row headers in GcSpreadSheet?
  • Replied 6 June 2018, 3:17 am EST

    To be more precisely, I mean to lock the width of column header and to lock the height of row header, not the widths of columns theirself neither the heights of rows.
  • Replied 7 June 2018, 8:18 am EST

    Hello,

    You can use SetColumnResizable and SetRowResizable methods :

    gcSpreadSheet1.Sheets[0].SetColumnResizable(0, GrapeCity.Windows.SpreadSheet.Data.SheetArea.ColumnHeader, false);
    gcSpreadSheet1.Sheets[0].SetRowResizable(0, GrapeCity.Windows.SpreadSheet.Data.SheetArea.RowHeader, false);

    Thanks,
    Deepak Sharma
  • Replied 8 June 2018, 7:07 am EST

    Hello,
    sorry for the missunderstanding. I want to prevent the corner header to be resized. Please see attached pciture.
  • Replied 8 June 2018, 8:28 am EST

    Hello,

    You can use code as follows:

    gcSpreadSheet1.Sheets[0].SetRowResizable(0, GrapeCity.Windows.SpreadSheet.Data.SheetArea.CornerHeader, false);

    Thanks,
    Deepak Sharma
  • Replied 11 June 2018, 3:13 am EST

    Hello, of course I did this setting before I sent the post but did not work. I got the exception again:

    2018/06/11 09:10:07.875|1|Error|Procam.Gdm.Presentation.App.HandleException|Error ocurred: 'The operation is not supported in the corner area.':
    at GrapeCity.Windows.SpreadSheet.Data.Worksheet.SetRowResizable(Int32 row, SheetArea sheetArea, Boolean value)
    at Procam.Gdm.Controls.Canvas.UserControls.GdmSpreadSheet.OnGdmSpreadSheetLoaded(Object sender, RoutedEventArgs e) in c:\Workspaces\print3\Procam.Gdm.Controls\Canvas\UserControls\GdmSpreadSheet.cs:line 66
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
    at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
    at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
    at MS.Internal.LoadedOrUnloadedOperation.DoWork()
    at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
    at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
    at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
    at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)|

    I also tried:
    gcSpreadSheet1.Sheets[0].SetRowResizable(-1, GrapeCity.Windows.SpreadSheet.Data.SheetArea.CornerHeader, false);
    as for the corner the value is -1. But it does not work neither with 0 nor -1.
  • Marked as Answer

    Replied 11 June 2018, 8:17 am EST

    Hello,

    In that case you can hard code the height and width of rowheight and columnwidth. You can check if the row in column header or column in rowheader is being resized and then set the width/height, something like:

     private void gcSpreadSheet1_MouseDown(object sender, MouseButtonEventArgs e)
    {
    HitTestInformation info = gcSpreadSheet1.HitTest(e.GetPosition(gcSpreadSheet1).X, e.GetPosition(gcSpreadSheet1).Y);
    if (info.HitTestType == HitTestType.Corner)
    {

    if (info.HeaderInfo.InColumnResize && info.HeaderInfo.Column == 0)
    {
    e.Handled = true;
    gcSpreadSheet1.Sheets[0].RowHeader.Columns[0].Width = 40;
    }

    if (info.HeaderInfo.InRowResize && info.HeaderInfo.Row == 0)
    {
    e.Handled = true;
    gcSpreadSheet1.Sheets[0].ColumnHeader.Rows[0].Height = 40;

    }
    }


    }


    Thanks,
    Deepak Sharma
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels