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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert checkbox in shortcut or menu

Status
Not open for further replies.

ameedoo3000

IS-IT--Management
Sep 20, 2016
233
EG
hi all
how can i insert checkbox in shortcut or menu
i have shortcut in the frist image . i want to inset checkbox in this menu as the second image. how can do that
one_qx920b.png

tow_jsjjz9.png
 
VFP menus natively support checkmarks, but not with a checkbox that shows when the item is unchecked. Take a look at the SET MARK OF command. (Don't confuse it with SET MARK TO.)

Tamar
 
Even if using that (SET MARK OF) I don't think this'll make you or your users happy, because once you check/uncheck one item, the context menu disappears. Do a new form for this. Take a look at how Windows Explorer manages columns visibility, especially adding further available columns, that's not just a context menu, that's a popup form with what compares to a VFP listbox with moverbars (for the order of columns) and includes a checkbox.

Bye, Olaf.
 
The way I would do this is to create a small form, and populate it with a two-column grid. One column would contain the checkbox, the other would contain the name of the column in the main grid (and that second column would be read-only). Remove the grid lines, and make the grid fit exactly into its parent form. Also, remove the title bar of the parent form, and sets its BorderStyle to None.

Then, instead of calling a menu (as shown in your screenshot), you would open this new form. Let the user make the choices, and then act on them. Of course, you would need a cursor to populate the grid, but it will be simple to create that.

Going further, make the form modeless, and use the Click or InteractiveChange of the checkbox to initiate the showing/hiding of the columns in the main grid. That way, the user can see the effect of his choices immediately.

Finally, close the form from its Deactivate event. In other words, the form will close as soon as the user clicks anywhere outside of it (but this will only work if the form is modeless).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
thank you very much dear OlafDoschke and dear MikeLewis. New and correct ideas and a direct solution.
 
One alternative you could consider is to put a ComboBox into a field in your Grid.

That would give the users the possibility of making a choice among various values (sort of like from a Checkbox menu or OptionGroup menu).

If you are interested, do a Search in this forum area for: grid combobox
You will find the topic discussed and how to do it.

Good Luck,
JRB-Bldr





 
thanks dear jrbbldr.
The problem still exists. the combo-box is disappearing after the First click on the items .and it can not be put a checkbox in it.The best solution is a separate form
 
If you do decide to opt for a separate form, let me add a point to my earlier post:

Rather than launching the form each time the user wants to use this feature, you could simply toggle its visibility.

In other words, launch the form as normal the first time the user invokes it. Then, instead of closing the form, just set its Visible property to .F. The next time the user wants to invoke it, set the Visible to .T. and so on. This will be quicker than constantly opening and closing it.

You will also need to consider the position of the form on the screen. Ideally, it should appear either at the mouse position or in the column headers of the main grid (in practice, these probably amount to the same thing). You would set the form's Left and Top to achieve that, and you would do that immediately before making it visible.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yes, the idea of the form is a great idea and very suitable for me, and I will implement the recommendations suggested by you. Thank you very much dear MikeLewis.
 
please...how can i re-visible the sub-form from main form (the Code)
the main-form(Frist) and the sub-form(Second)
i use this code ------ second.visible=.T. ------ by click command button in Frist
this Error message appear
Untitled_gaoszf.png
 
This is not as simple as Mike suggests it is. In the first place you have to avoid the new form to release and vanish, but only let it hide. Since any fiorm has the typical upper right X close button that already means you need to take control about that and not let it close and release the form, which can be done via the QueryUnload().

I won't go into the details of all this, what seems easy, to hide and show a form, in reality is not, if you are only used to DO FORM and not the object oriented way to instanciate a form class as an object. That will mean to teach a lot, just to let you hide/show a form instead of restarting it.

I would rather suggest you forget about that and handle the form as you're used to, as that now is a lot to learn and understand and test and stabilze to gain a marginal advantage. To be able to let a form stay loaded only really pays, if starting the form needs more time than a user will regard as accaptable wait time for the step of his workflow, so it will mainly only play a role for very complex forms loading a lot of data in their initialization and take more than one or two seconds to load. I doubt a form with 5-20 options will take more than split seconds to be started up, so you're fine with restarting the form each time.

Bye, Olaf.
 
Olaf said:
Since any fiorm has the typical upper right X close button that already means you need to take control about that and not let it close and release the form, which can be done via the QueryUnload().

That's why I suggested setting the TitleBar to 0 (and also set Closable to .F.)

This is what I had in mind:

1. In the main form (the one containing the grid whose columns you want to show/hide), create a custom property called, say, oMenu, and initially set it to NULL.

2. In the main form's Init, open the subsidiary form but keep it invisible: [tt]DO FORM MenuForm NAME THISFORM.oMenu NOSHOW[/tt].

3. When you want to make the subsidiary form visible: [tt]THISFORM.oMenu.Visible = .T.[/tt]

4. And when you want to hide it: [tt]THISFORM.oMenu.Visible = .F.[/tt]

However, I agree with Olaf's main point. If all this sounds difficult or complicated, just forget it. Open and close the form in the usual way. Any extra time that that involves will be fairly negligible.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
ameedoo3000 said:
The problem still exists. the combo-box is disappearing after the First click on the items .and it can not be put a checkbox in it.

I know that a checkbox cannot be put into the ComboBox.
I suggested using a ComboBox INSTEAD of a checkbox since they both give the user a choice of multiple values (like shown in the checkbox list picture in your original posting) and only one value may be selected to appear in the Grid's field.
Plus a ComboBox can work in a Grid fairly easily where multiple checkboxes cannot.

I am not sure what you mean when you say:
the combo-box is disappearing after the First click
If you follow the instructions in the previous postings, everything should work fine.

Regardless of which approach you take - Good Luck,
JRB-Bldr




 
thank you dear jrbbldr for helps. i mean (the combo-box is disappearing after the First click) with (only one value may be selected).
I wanted to show me all the checkbox or all marks in order to choose more than one option at a time. But this does not seem to be available in Fox Pro. However, thank you very much for your help and for your time.
 
I wanted to show me all the checkbox or all marks in order to choose more than one option at a time. But this does not seem to be available in Fox Pro.

You certainly can shows "more than one option at a time" with checkboxes. Each checkbox can be ticked or un-ticked independently of any other checkboxes.

Are you perhaps confusing checkboxes with option buttons? Unlike checkboxes, option buttons are mutually exclusive. Selecting one of them deselects all the others in the group.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
dear MikeLewis.
I tried to execute all the previous steps in order for the subform to appear through a code from within the original form. However, there is a problem that the subform is always under the original form . The steps I followed are:
1-create main form (form1)and create new property named(omenu)and set initially to .f.
2-create sub-form (form2) and set property titlebar to (0) and property closable to .f. and visible to (False).
3- in the event lnit of (form1) this code (DO FORM Form2.scx NAME thisform.omenu).
4- when i run form1 the form2 only appear and when i hide it (form1) apear and form2 still behind form1 all time after .
what is the problem ?
1_vklsta.png

2_syfldq.png

3_v4ws4g.png
 
You missed the NOSHOW keyword in the DO FORM command (Step 2 in my post).

If that doesn't solve the problem, try this: Instead of setting Form 2's Visible property to .T. to make the form visible, try calling its Show method instead.

But, as I said before, if you find you are spending too much time on this (and if you don't understand the basic issues), don't worry about it. Just open and close the form in the usual way, that is, with DO FORM and THISFORM.Release.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
ok. i add noshow to end of the code (DO FORM Form2.scx NAME thisform.omenu Noshow) now it is ok but form2 still show behind form1 not in the front why?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top