# Wx:Grid Setting Cursor Position

**URL:** <https://www.ruby-forum.com/t/wx-grid-setting-cursor-position/219949>\
**Category:** wxRuby\
**Created:** [May 22, 2012, 11:29pm UTC](https://www.ruby-forum.com/t/wx-grid-setting-cursor-position/219949 "2012-05-22T23:29:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [May 22, 2012, 11:29pm UTC](https://www.ruby-forum.com/t/wx-grid-setting-cursor-position/219949/1 "2012-05-22T23:29:03Z")

</div>

I’m using the grid widget with an underlying GridTableBase and trying to  
implement a “Find” button which would cause the current cursor position  
to go to the next matching cell. I’m wondering if there’s an easy way  
to do it? I’m playing with the Grid.select\_block\_row(),  
Grid.set\_grid\_cursor() and Grid.scroll() methods, but the results are a  
bit erratic.

Is there a better way to do this than using Grid.move\_cursor\_down/right?

Thanks,  
Norbert

---

<div class="post-metadata">

**Author:** ![norbertl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c77e96/32.png) [@norbertl](https://www.ruby-forum.com/u/norbertl)\
**Post date:** [May 24, 2012, 5:27pm UTC](https://www.ruby-forum.com/t/wx-grid-setting-cursor-position/219949/2 "2012-05-24T17:27:47Z")

</div>

It took a bit of time and experimenting, but this seems to work, for  
anyone  
else who’s maybe run into the same issues. Here’s the code I came up  
with for scrolling to a grid position given a cell row and column. I  
hope someone finds it useful.

Norbert

---

<div class="post-metadata">

**Author:** ![norbertl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c77e96/32.png) [@norbertl](https://www.ruby-forum.com/u/norbertl)\
**Post date:** [June 11, 2013, 7:45pm UTC](https://www.ruby-forum.com/t/wx-grid-setting-cursor-position/219949/3 "2013-06-11T19:45:44Z")

</div>

A bit of a tweak in case someone has used this code. The original  
didn’t take into account the width and height of the row and column  
labels in calculating whether to reposition the grid.

Norbert
