Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on Control

Status
Not open for further replies.

newtofoxpro

Programmer
Sep 16, 2007
301
IN
I have added three textboxs. one,two,three .
At When event of two, I have added Grid Control and focus on it. When I press <enter> focus should shift to control three. Or press <Shift+Tab> control should shift to one.

How to do this ?

Best Regards.
 
When you create a grid in textbox two the textbox two has lost focus, only one control has focus. If you want to move in tab order from two to three REURN is correct, TAB is also possible, if you want to move to one SHIFT+TAB is right, but two has no focus anymore, you set focus to the grid and it has taborder 4. There is no way around that.

Bye, Olaf.
 
Thank for reply post.

When the focus is on grid. Can I get the name of the control where grid object added. i.e. two.
 
For a textbox (and any other control), check the ActiveControl property of the form (or other parent container). So, for example, if focus is on Text1, then THISFORM.ActiveContol.Name will contain Text1.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, you add the grid from textbox two, so in it's initialisation you could pass on THIS as CREATEOBJECT or ADDOBJECT parameter, whcih arrives in grid.init. You could also read ActiveControl in the Init of the grid, but that would depend on the control creating the grid being the active control, in then WHEN event, this isn't yet the case.

In both solutions, you would need to create your own grid class, not the native grid, as you need code to receive parameters or configuration. You can't add code at runtime.

Bye, Olaf.
 
I would rather do a control based on container with a textbox and a grid in case you want to imitate something like a combobox with a grid eg as datepicker. Then you have a preset tab order within that compound class, the grid is not set at the last tabposition in the form, you simply can show/hide the grid and the only "weird" thing you would need to care for is, that a backtab from the grid goes to the textbox it drops from. But you might keep it that way and don't need to handle any tabbing navigational aspects.

the container based class integrates into form tab order and the order of inner controls is sepearet from the form tab order, since the grid is the second control within the container a tab/return from it would move on to the next control in form tab order after the container.

At another quesstion I suggested creating additional controls on the fly, more like ppopup forms, but in both cases, if you have a compound control, it belongs into it's own class based on container.

Bye, Olaf.
 
Yes I need datapicker. My first try is passing parameter from textbox's when event this.name to grid. Everything is ok upto here. Please give me time to build. Thanks.
 
I wouldn't pass on this.name nor this in your case, I already sayid you should rather do a class based on container and add a textbox and grid to it, then there is no need to pass on object references nor names, they are known from the outset.

Bye, Olaf.
 
Yes, you are right, adding textbox & grid to container is flexible. My trial code is working now.
 
Now Problem arise. I have used three controls
one = Textbox Class
two = Container having textbox & grid
three = Textbox Class

When Container design with BackStyle = 0 , BorderWidth = 0
Initialize Grid visible = .f.
Now focus is on one (texbox) everything is fine here.
Now focus on container textbox Grid visible = .t. via textbox.InterActiveChange
Control three is still visible between grid.
 
That's a zorder problem.

If you put three on the area of two, the grid displays under three, don't put controls in the area, overlap is not good.

You can only have the whole container in front of three or behind it, you cannot have only the grid at the top.

What you can simply try out it click on two, in menu: Format->Bring To Front. You will then have the problem to not be able to click through the container on three. A click on the area of the container will activate the container and the textbox/grid in it.

There's not much you can do about that, generating the grid at runtime has the advantage it's in front of everything, but it's taborder then is last. I'm still in favor of the container solution.

Bye, Olaf.
 
An idea to solve the problem: Let the container have an initial height the same as the textbox, and only when you actiavte and show the grid, also expand the container. Still the container must have a zorder in front of everything.

At runtime you can call THIS.Zorder(0) to make this object come to the front.

So in your textbox.InteractiveChange you do This.Parent.Grid.Visible = .T. and This.Parent.Height = 300 and This.Zorder(0).

And the moment you Hide the grid you also do This.Parent.ResetToDefault("Height") and the height will go back to textbox height.

That should work out, haven't tested it, though. This.Parent would be valid in a textbox method/event, it should reference the container of course. In a container method it would just be THIS of course.

Bye, Olaf.
 
Thank you. Upto this time, only this.Parent.ZOrder(0) in text1.InterActiveChange working for me.
 
So?

I don't know your code to finish picking a data and hiding the grid again. At that place you have to reset the container height. That shouldn't be difficult to adopt to your situation.

Bye, Olaf.
 
OlafDoschke, I agree with you again. What do you think this class should work with another grid ?

Example

WITH this.Column2
.RemoveObject('Text1')
.Addobject("mxxxx","ContainerTextGrid")
 
No, within a grid using this compound control, enlarging the container would higher the outer grid row, this will at least not look good. I don't think the outer grid will react dynamically on it's own, at least you need to refresh the outer grid, before the enlarged container will get visible. zorder will not put it in front of the grid.

So if you want a date picker inside a grid you better have it in enlarged mode all the time, if you use sparse=.t. this would perhaps work, but not look good anyway.

For that case you should rather use a dategrid you create at runtime in front of the grid, but then have the problem with tab order again.

You can't get around all problems at the same time, unless you use some ActiveX datepicker, there are more than the MS Datepicker.

Bye, Olaf.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top