# Keeping columns in view in a grid

**URL:** <https://www.ruby-forum.com/t/keeping-columns-in-view-in-a-grid/207761>\
**Category:** wxRuby\
**Created:** [June 2, 2011, 2:57am UTC](https://www.ruby-forum.com/t/keeping-columns-in-view-in-a-grid/207761 "2011-06-02T02:57:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 2, 2011, 2:57am UTC](https://www.ruby-forum.com/t/keeping-columns-in-view-in-a-grid/207761/1 "2011-06-02T02:57:59Z")

</div>

I’m writing an application using wxruby in which the main portion is  
essentially a spreadsheet using a Grid widget. The extent of the Grid  
is  
such that it exceeds the available space that can be seen at once, so it  
will be necessary to use scrollbars to see data as necessary. However,  
the  
first two columns should stay in view even when the Grid is scrolled  
horizontally. (They contain names and ID numbers, so it would be  
confusing  
to have them go out of view when the grid is scrolled to the right.)  
Does  
anyone have suggestions on how to accomplish this?

---

<div class="post-metadata">

**Author:** ![will\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a87d85/32.png) [@will\_p](https://www.ruby-forum.com/u/will_p)\
**Post date:** [June 4, 2011, 4:57pm UTC](https://www.ruby-forum.com/t/keeping-columns-in-view-in-a-grid/207761/2 "2011-06-04T16:57:10Z")

</div>

Will P. wrote in post #1002674:

> I’m writing an application using wxruby in which the main portion is  
> essentially a spreadsheet using a Grid widget. The extent of the Grid  
> is  
> such that it exceeds the available space that can be seen at once, so it  
> will be necessary to use scrollbars to see data as necessary. However,  
> the  
> first two columns should stay in view even when the Grid is scrolled  
> horizontally. (They contain names and ID numbers, so it would be  
> confusing  
> to have them go out of view when the grid is scrolled to the right.)  
> Does  
> anyone have suggestions on how to accomplish this?

I’m not sure that the wxGrid control supports the ability to “freeze”  
columns.

If not, you could perhaps use 2 grids, side by side, with the left grid  
displaying the first two columns of your data and the right grid  
displaying the remaining columns. You’d need, of course, to keep them in  
sync as you scroll down through the rows.

David

> **[Ruby on Windows](http://rubyonwindows.blogspot.com)**
>
> On using the Ruby programming language on the Microsoft Windows platform

---

<div class="post-metadata">

**Author:** ![will\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a87d85/32.png) [@will\_p](https://www.ruby-forum.com/u/will_p)\
**Post date:** [June 7, 2011, 5:05pm UTC](https://www.ruby-forum.com/t/keeping-columns-in-view-in-a-grid/207761/3 "2011-06-07T17:05:23Z")

</div>

the easiest way to accomplish this is to merge your two columns into one  
and put them into the row label. It might not be what you’re looking for  
but it’s definitely less effort than syncing two grids.

T
