Topic: Clearing drop down menu selections

Greeting to all,

I have build an application to log my orders. It has several drop down menus.
I need to program a new button that will automatically erase the values that have been selected in the drop down menus. Can someone help me with an example of such a code?

For example I have 2 drop down menus.
One for selecting the car manufacturer and one for selecting the model.
Once I have made my selections I usually search my orders database for all matching entries.
After that I need to clean the previous selections in the drop down lists for my next search. How can I do this?

Thank you
George

Re: Clearing drop down menu selections

Hello,



Example:

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
    Form1.ComboBox1.dbItemID := -1;
    Form1.ComboBox2.dbItemID := -1;
end;
Dmitry.

Re: Clearing drop down menu selections

I tried your code but I get an error "Begin expected at 7:1"

I understand that I have to change "Form1" to the name of my form and
"ComboBox1" to the name of my dropdown list

Can you please help?

Thanks
George

Re: Clearing drop down menu selections

I forgot to mention that the code runs even with this error message but when I click on the button to reset the dropdown lists nothing happens.

Thank you
George

Re: Clearing drop down menu selections

I suppose you have delete last section

begin

end.

You should not do it.


Also you should create event (procedure Form1_Button1_OnClick)
not just paste to script, here you can see, how to create an event
http://myvisualdatabase.com/help_en/scr … rview.html



your result script should be:

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
    Form1.ComboBox1.dbItemID := -1;
    Form1.ComboBox2.dbItemID := -1;
end;


begin

end.
Dmitry.

Re: Clearing drop down menu selections

Ok i found it.

A begin end. statement wasmissing.

Your instructions were correct and everything is workin fine.

Thank you for your help.

Regards

George

Re: Clearing drop down menu selections

Hi

In the same form I also have some simple text fields. How can I clean the contents of these fields with a click of a button on the form?

Can someone please recommend a good book to learn to program in MyvisualDatabase?

Thanks
George

Re: Clearing drop down menu selections

Hello George,
Is this the sort of thing you're after?  (see attachment).
There isn't really any book for MVD although general references for Delphi, Pascal etc might help. 
The videos that Dmitry took are a good place to learn the very basics and the help file is okay too. 
But for me, the best source for learning is the forum itself, particularly downloading various attachments and just seeing how other users have done things.
Good luck,
Derek.

Post's attachments

Attachment icon geochrist.zip 336.03 kb, 543 downloads since 2016-11-22 

Re: Clearing drop down menu selections

Hello Geochrist, hello Derek

Let's suppose you have 20 Tedit components on your form.

If you enter 20 times the same instruction, at the end you will no longer have fingers.
This may be useful to empty the contents of TEdit at one time.
For this purpose, I have made a small loop that empty the content of all TEdit (but this can apply to all other components present on the form):
See attachment (this way because an error occured in the writing of the text)
To place behind a Form1.Buttonx.Click

JB

Post's attachments

Attachment icon Edit_Clear.txt 246 b, 571 downloads since 2016-11-22