Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Selecting a cell in gridctrl
Selecting a cell in gridctrl [message #12220] Fri, 19 October 2007 00:20 Go to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Hello,

I am currently writing an application that is displaying the contents of a file in hex and ascii. I am using gridctrl to contain the data. What I am trying to do is allow the user to select a cell in one gridctrl and have the corresponding cell in the other gridctrl be highlighted. Is this possible? I was trying to figure out how to get the cell location and managed to get the row information and get the row selected on the other gridctrl, but I was unable to figure out how to get the column.

Thank you for any help you can give me.

Dave
Re: Selecting a cell in gridctrl [message #12224 is a reply to message #12220] Fri, 19 October 2007 08:28 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

What about Point GetCursorPos() ? Smile
Re: Selecting a cell in gridctrl [message #12230 is a reply to message #12224] Fri, 19 October 2007 19:32 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
That only solves part of the problem. I still need to highlight the corresponding cell in the other gridctrl.

Thanks,

Dave
Re: Selecting a cell in gridctrl [message #12231 is a reply to message #12230] Fri, 19 October 2007 19:52 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Just use SetCursor(Point p)
Re: Selecting a cell in gridctrl [message #12235 is a reply to message #12231] Sat, 20 October 2007 01:49 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Where is that function defined? I am using 710-dev1 and the only version of the function is SetCursor(int n). Has there been an update to gridctrl for that function?

Thanks,

Dave
Re: Selecting a cell in gridctrl [message #12237 is a reply to message #12235] Sat, 20 October 2007 11:18 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

dmcgeoch wrote on Fri, 19 October 2007 19:49

Where is that function defined? I am using 710-dev1 and the only version of the function is SetCursor(int n). Has there been an update to gridctrl for that function?

Thanks,

Dave

Opps, I'm sorry. There is SetCursor0(Point p) which is not public. Sorry for mistake..
Anyway please add for now to gridctrl interface:
void SetCursor(Point p) { SetCursor0(p.x + fixed_cols, p.y + fixed_rows, false); }

I'll add it this in the next dev snapshot.
Re: Selecting a cell in gridctrl [message #12262 is a reply to message #12237] Mon, 22 October 2007 16:33 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Thanks, That did the trick. Now the next question is can you get feedback from when the arrow keys are used to step around the grid. I believe I found where the keys are processed, but not if the information is returned. Is there a generic "When" callback that will let the program know that the active cell position has changed?

Thanks,

Dave
Re: Selecting a cell in gridctrl [message #12272 is a reply to message #12262] Mon, 22 October 2007 23:19 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Hi!

There is WhenChangeRow but it is not called when cursor changes position horizontaly. There is also no key callback, but I think I could provide one. I will also add WhenCursorChange. In most cases I use "row mode", that's why grid lacks some callbacks Wink In the meantime (before new dev) you must update grid code manually..
Re: Selecting a cell in gridctrl [message #12295 is a reply to message #12272] Tue, 23 October 2007 20:26 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Hi,

Attached is an updated version of GridCtrl.cpp and GridCtrl.h that have the SetCursor(Point) change and an additional callback WhenChangeCol. So far it seems to work the way I want. Thank you for all your help.

Dave
  • Attachment: GridCtrl.cpp
    (Size: 139.53KB, Downloaded 357 times)
  • Attachment: GridCtrl.h
    (Size: 47.64KB, Downloaded 394 times)
Re: Selecting a cell in gridctrl [message #12447 is a reply to message #12220] Thu, 01 November 2007 18:02 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Hi!

The next problem I've run into is I can't seem to force GridCtrl to scroll if the selected cell is off screen. I tried to used the ScrollView function, but it appears to have no effect. I tried all the available variants of ScrollView with no change. Is there something else I am missing?

Thanks,

Dave
Re: Selecting a cell in gridctrl [message #12448 is a reply to message #12447] Thu, 01 November 2007 18:36 Go to previous messageGo to next message
mezise is currently offline  mezise
Messages: 54
Registered: April 2006
Member
Hi,

grid.Absolute();

works for me.

PS: this is not a "Selecting a cell in gridctrl" problem so please make of it another topic.

Michal
Re: Selecting a cell in gridctrl [message #12449 is a reply to message #12447] Thu, 01 November 2007 18:47 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Quote:

The next problem I've run into is I can't seem to force GridCtrl to scroll if the selected cell is off screen. I tried to used the ScrollView function, but it appears to have no effect. I tried all the available variants of ScrollView with no change. Is there something else I am missing?

You can use GotTo(int row) method to make the given row visible. There is no method to do the same in horizontal direction however so I will overload GotTo to make it possible.
You can also make public sbx and sby members and use their methods to force scrolling (SetPos). Of course it's not a proper way, but it can temorarly solve your problems.
Re: Selecting a cell in gridctrl [message #12451 is a reply to message #12449] Thu, 01 November 2007 19:23 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Hi!

Using GoTo solves the problem. At this time I am only concerned with scrolling by row, so I don't need the fix for horizontal scrolling.

Thank you for your help,

Dave
Re: Selecting a cell in gridctrl [message #12452 is a reply to message #12451] Thu, 01 November 2007 21:27 Go to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

That's great! I've just added your previous patch (WhenChangeCol) and GoTo(int row, int col).
Previous Topic: GridCtrl crash when cancel insert/update
Next Topic: Row numbering inconsistency
Goto Forum:
  


Current Time: Mon Apr 29 17:02:00 CEST 2024

Total time taken to generate the page: 0.02848 seconds