Gtk.TreeView - dynamic scrolling

View: New views
5 Messages — Rating Filter:   Alert me  

Gtk.TreeView - dynamic scrolling

by Philip Wobst-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a TreeView with elements that have a date and time column and I would like to have my application scroll to the position in the TreeView that is nearest to the current time when the TreeView is displayed. Is there any way of doing this?

Any suggestions would be gladly appreciated.


_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Re: Gtk.TreeView - dynamic scrolling

by jmauster :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I assume you can easily find which row has the closest time.  (A simple foreach measuring the distance between Now and the Datetime while keeping track of the lowest value would a simple but ineffective way to get this done.)
 
Once you have the index of the row you want:
 
dataGridView1.FirstDisplayedScrollingRowIndex = index;
dataGridView1.Refresh();
 
 
Hope that helps,
 


 
On Wed, Jul 8, 2009 at 8:47 AM, Philip Wobst <philip.wobst@...> wrote:
I have a TreeView with elements that have a date and time column and I would like to have my application scroll to the position in the TreeView that is nearest to the current time when the TreeView is displayed. Is there any way of doing this?

Any suggestions would be gladly appreciated.


_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list



_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Re: Gtk.TreeView - dynamic scrolling

by Philip Wobst-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry for not being clear about this - your solution describes exactly what I am intending to do - however, I need the solution for a Gtk.TreeView. (Thanks for the prompt reply)

On Wed, Jul 8, 2009 at 9:10 AM, Evan Arnold wrote:
I assume you can easily find which row has the closest time.  (A simple foreach measuring the distance between Now and the Datetime while keeping track of the lowest value would a simple but ineffective way to get this done.)
 
Once you have the index of the row you want:
 
dataGridView1.FirstDisplayedScrollingRowIndex = index;
dataGridView1.Refresh();
 
 
Hope that helps,
 


 
On Wed, Jul 8, 2009 at 8:47 AM, Philip Wobst <philip.wobst@...> wrote:
I have a TreeView with elements that have a date and time column and I would like to have my application scroll to the position in the TreeView that is nearest to the current time when the TreeView is displayed. Is there any way of doing this?

Any suggestions would be gladly appreciated.


_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list



_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Parent Message unknown Re: Gtk.TreeView - dynamic scrolling

by Chris Howie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

(Re-sending since I didn't hit the list.  Sorry, Philip.)

On Wed, Jul 8, 2009 at 9:47 AM, Philip Wobst<philip.wobst@...> wrote:
> I have a TreeView with elements that have a date and time column and I would
> like to have my application scroll to the position in the TreeView that is
> nearest to the current time when the TreeView is displayed. Is there any way
> of doing this?

If you can determine the TreePath of that row (use the model to get
this from a TreeIter) then you should be able to use
treeView.ScrollToCell(iter, treeView.Columns[0], true, 0, 0) to do
this.

--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Re: Gtk.TreeView - dynamic scrolling

by Philip Wobst-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Works like a charm, this is great. Thank you Chris!

-----Ursprüngliche Nachricht-----
Von: Chris Howie [mailto:cdhowie@...]
Gesendet: Mittwoch, 8. Juli 2009 22:06
An: Gtk# mailing list
Cc: Philip Wobst
Betreff: Re: [Gtk-sharp-list] Gtk.TreeView - dynamic scrolling

(Re-sending since I didn't hit the list.  Sorry, Philip.)

On Wed, Jul 8, 2009 at 9:47 AM, Philip Wobst<philip.wobst@...> wrote:
> I have a TreeView with elements that have a date and time column and I
> would like to have my application scroll to the position in the
> TreeView that is nearest to the current time when the TreeView is
> displayed. Is there any way of doing this?

If you can determine the TreePath of that row (use the model to get this from a TreeIter) then you should be able to use treeView.ScrollToCell(iter, treeView.Columns[0], true, 0, 0) to do this.

--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list