Scrolling in a Disabled FlexGrid

The Set-Up

Occasionally, our customers come up with requests that not only surprise us, but inspire creativity within us. Some of these features don't apper valid on a plain white sheet, but nothing confines us in these stacks of white sheets. Take for instance, recently a customer inquired if it was possible to scroll a disabled FlexGrid. Many would probably first react with "Of course it is not! One cannot access a disabled control". In a fair world with stacks and stacks of white sheets this answer would sound perfect.

A disabled control is disabled. PERIOD.

The Confrontation

But we all know this is far from a perfect world. Tamper the meaning of disabled control, and you get to do a lot of things that you were not earlier able to. What we did there was, create an allusion of disabled control to the grid. Carefully hiding all the functionality in a gray cloak, only to provide a small window to perform a task : Scrolling.

The Gray Cloak

  • Prevent editing on the grid.
  • Prevent column header click's operation.
  • Remove the initial selection from the grid.
  • Prevent Selection by handling the "BeforeSelChange" event and cancel it.
  • Prevent any drop on the grid.
  • Disable KeyPress on grid.

Under the cloak

 private void DisableThisGridWithScolling(C1.Win.C1FlexGrid.C1FlexGrid grid)  
   //Step 1 : Disable Editing  
   grid.AllowEditing = false;  

   //Step 2 : Disable column header click's operation  
   grid.AllowSorting = AllowSortingEnum.None;  
   grid.AllowDragging = AllowDraggingEnum.None;  
   grid.AllowFiltering = false;  
   grid.AllowResizing = AllowResizingEnum.None;  

   //Step 3 : Disable default Selection  
   grid.Row = -1;  
   grid.Col = -1;  

   //Step 4 : Disable Selection  
   grid.BeforeSelChange += (s, e) =>{e.Cancel = true;};  

   //Step 5 : Disable Drop  
   grid.DropMode = DropModeEnum.None;  

   //Stop 6 : Disable KeyPress  
   grid.KeyPress += (s, e) => { e.Handled = true;};  

The Aftermath

Flex_Disabled For programmers and developers, workarounds act as a quick and effective remedy, mostly in scenarios where technology/design principles comes to a hindrance. This was one such example where a small trick did the task rendered impossible in a general scenario. You can share similar scenarios with ComponentOne Controls here. Please find the samples here: VB : ScrollingWhileDisabledGridVB C# : ScrollingWhileDisabledGrid


GrapeCity Developer Tools
comments powered by Disqus