Hi
I suspect that this is an easy question, but I cannot find the answer anywhere.
I currently have a multi-line wxTextCtrl with a variable number of lines of wrapped text, which is positioned above a wxGrid with a few more lines (say 20 or so) of tabular data, with both controls in a vertical wxBoxSizer. This works fairly well and is close to what I'm after, except that there are vertical scroll-bars on both the wxTextCtrl and the wxGrid.
How would I go about getting one vertical scroll-bar that would scroll both the wxTextCtrl and the wxGrid? Basically I would like the block of text above the wxGrid and the WxGrid itself to move as a unit when the vertical scroll bar is moved.
One scrollbar around wcTextCtrl and wxGrid
Re: One scrollbar around wcTextCtrl and wxGrid
Definitely not an easy question
First of all, can you post a screenshot? I don't see how it makes sense to scroll two controls that are on top of each other with one vertical scrollbar. I could understand it, if they were side by side.
However, the problem here is that wxTextCtrl is a native control and wxGrid is not, it will be very hard to make them scroll in parallel.
First of all, can you post a screenshot? I don't see how it makes sense to scroll two controls that are on top of each other with one vertical scrollbar. I could understand it, if they were side by side.
However, the problem here is that wxTextCtrl is a native control and wxGrid is not, it will be very hard to make them scroll in parallel.
Use the source, Luke!
Re: One scrollbar around wcTextCtrl and wxGrid
Here is a drawing of what I'm after.
-
- Filthy Rich wx Solver
- Posts: 235
- Joined: Fri Sep 14, 2012 8:26 am
- Location: Kontich, Belgium
- Contact:
Re: One scrollbar around wcTextCtrl and wxGrid
Hi Neil,
I would strongly advise against that kind of behaviour. An interface should be intuitive and logical. Sliders are introduced with windows. A way to say you page is of size A4 but your window is size A5, so you can only seen 1/2 of your page. That's why your vertcal slider will show a slider size of 50% telling you, you're only seeing half of your page. So basically a slider is fundamentally bound to the window or control in this matter.
It would be different if both control and grid are of fixed, actual size and together they form the content of a window with a vertical slider. That would mean using the slider, it will move you textcontrol out of sight, to show more of the grid.
regards,
Nunki
I would strongly advise against that kind of behaviour. An interface should be intuitive and logical. Sliders are introduced with windows. A way to say you page is of size A4 but your window is size A5, so you can only seen 1/2 of your page. That's why your vertcal slider will show a slider size of 50% telling you, you're only seeing half of your page. So basically a slider is fundamentally bound to the window or control in this matter.
It would be different if both control and grid are of fixed, actual size and together they form the content of a window with a vertical slider. That would mean using the slider, it will move you textcontrol out of sight, to show more of the grid.
regards,
Nunki
Re: One scrollbar around wcTextCtrl and wxGrid
Based on that image, i don't see why dragging the scrollbar should also scroll the text control. What kind of information are you displaying in there?neilsp wrote:Here is a drawing of what I'm after.
I think you're either building a very unusual (= bad) GUI, or you're using a wxTextCtrl for something it's not made for.
Use the source, Luke!
Re: One scrollbar around wcTextCtrl and wxGrid
I must be miss-communicating here, since I am not trying to do any kind of fancy synchronized scrolling of the text and grid controls.
Nunki fairly well described what I'm after:
Nunki fairly well described what I'm after:
Basically, as shown in my earlier drawing, I just want to show some descriptive text above a table of information and have the whole thing move up and down in a window, when the window it not big enough to show the whole thing at once.It would be different if both control and grid are of fixed, actual size and together they form the content of a window with a vertical slider. That would mean using the slider, it will move you textcontrol out of sight, to show more of the grid.
Re: One scrollbar around wcTextCtrl and wxGrid
Sorry, i totally misunderstood your original question.
But from a GUI point of view it still doesn't make sense to me. If the upper text control is descriptive text, wouldn't it be better if only the wxGrid scrolled its content, so that the descriptive text is visible all the time instead of scrolling out of view?
In any case, if i understand you correctly now, you only need to add one wxScrolledWindow and one wxSizer into the hierarchy to achieve what you want.
Right now you have:
New:
But from a GUI point of view it still doesn't make sense to me. If the upper text control is descriptive text, wouldn't it be better if only the wxGrid scrolled its content, so that the descriptive text is visible all the time instead of scrolling out of view?
In any case, if i understand you correctly now, you only need to add one wxScrolledWindow and one wxSizer into the hierarchy to achieve what you want.
Right now you have:
Code: Select all
- wxBoxSizer(wxVERTICAL)
-- wxTextCtrl
-- wxGrid
Code: Select all
- wxBoxSizer(wxVERTIVAL)
-- wxScrolledWindow (new)
--- wxBoxSizer(wxVERTICAL) (new)
---- wxTextCtrl
---- wxGrid
Use the source, Luke!