Topic: unbound dropbox list

is there a way to use the ComboBox as an unbound dropdown list?  In other environments, I could add items to the list items to display within the drop down rather than assigning to a table and field.  Can this be accomplished in mvd?

RK

Re: unbound dropbox list

I think I figured it out.  Seems to work.

   ComboBox1.Items.Clear;           
  ComboBox1.Items.Add('Red');       
  ComboBox1.Items.Add('Green');

Re: unbound dropbox list

Hello rjkantor

ComboBox1.Items.Add('Red'), ......; is the way, but if there are many items to add,
you will avoid component Combobox redraw each time you add,

For me, when I wad wotking with Delphi 7 (damn it now I use windows 10) I used this code :

ComboBox1.Items.BeginUpdate;
ComboBox1.Items.Clear;
ComboBox1.Items.Add('Un');
ComboBox1.Items.Add('Deux');
ComboBox1.Items.Add('Trois');
ComboBox1.Items.Add('Quatre');
ComboBox1.Items.EndUpdate;

It worked fine also with ListBox1.Items and Memo1.Lines.Add
I've not yet tested with MVD

JB

Re: unbound dropbox list

Hello,

I tried this but i cant get in to work in my project, could you provide an example?

Many thanks,

Kind regards

Re: unbound dropbox list

dbk wrote:

Hello,

I tried this but i cant get in to work in my project, could you provide an example?

Many thanks,

Kind regards

It depends how you use this ComboBox, please provide more details and attach your project.

Dmitry.

Re: unbound dropbox list

DriveSoft wrote:
dbk wrote:

Hello,

I tried this but i cant get in to work in my project, could you provide an example?

Many thanks,

Kind regards

It depends how you use this ComboBox, please provide more details and attach your project.

Hello,

When i try to script it using onclick event i get an error 'undeclared identifier'

Re: unbound dropbox list

Attach your project I will check it.

Dmitry.

Re: unbound dropbox list

Hello

procedure Form1_ComboBox2_OnClick (Sender: TObject);
begin
 ComboBox2.Items.Add('test');
end;

What could be wrong?

Thanks

9 (edited by sibprogsistem 2018-11-21 22:55:22)

Re: unbound dropbox list

procedure Form1_OnShow (Sender: TObject; Action: string);
begin
   Form1.ComboBox1.Items.Add('test');
end;

10

Re: unbound dropbox list

sibprogsistem wrote:
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
   Form1.ComboBox1.Items.Add('test');
end;

Ah yes, it works, thank you!!

11

Re: unbound dropbox list

Hello,

sorry to ask again, but i seem to have a problem when using this method in multiple forms.

I have this:

procedure Form1_OnShow (Sender: TObject; Action: string);
begin
   Form1.ComboBox1.Items.Add('Male');
   Form1.ComboBox1.Items.Add('Female');
end;

This works on Form1, now i have a second form Form2, i try to use the same code for a combobox in Form2:

procedure Form2_OnShow (Sender: TObject; Action: string);
begin
   Form2.ComboBox1.Items.Add('Item one');
   Form2.ComboBox1.Items.Add('Item two');
end;

And this does not work on Form2, i tested with other forms / other comboboxes but the code only works on Form1.

Any ideas?

Re: unbound dropbox list

Hello.


I have checked, it works for me. Please attach your project, I'll check it.



For what purpose are you use this method to add data to ComboBox?
You must understand, that you can't use these ComboBoxes to save data to database without additional script.

Dmitry.

13 (edited by sibprogsistem 2018-11-29 16:42:13)

Re: unbound dropbox list

you have a mistake somewhere

Post's attachments

Attachment icon Form2.rar 2.5 kb, 519 downloads since 2018-11-29 

14

Re: unbound dropbox list

sibprogsistem wrote:

you have a mistake somewhere

thank you for the help sibprogsistem! i really appreciate it! i am searching for the mistake

15 (edited by dbk 2018-11-29 22:18:06)

Re: unbound dropbox list

DriveSoft wrote:

Hello.


I have checked, it works for me. Please attach your project, I'll check it.



For what purpose are you use this method to add data to ComboBox?
You must understand, that you can't use these ComboBoxes to save data to database without additional script.

Hello Dmitry,
Thanks for checking. Ok, so actually i am trying to save the value to the database, so i understand i am doing it wrong. I have a lot of forms with a lot of comboboxes but the values of the comboboxes will not change often, so thats why it would be easy to 'hardcode' it in the dropdown itself so the selected string would be entered in the table. However, almost each form has different comboboxes with different values to select. Right now, i am 1.) making a table 2.) designing a form to add values to this table 3.) add relationship to the tables, just to fill out some comboboxes like "Gender: male or female?" of a list of countries for example. This is kind of tedious. Should i make the tables directly in the sqlite database through a sqlite management app or am i doing it right as i am doing it now? Is there an easier way?

Thanks

Re: unbound dropbox list

Yes, sometime it's tedious, but it's right way.


You can create one form for data like Gender or Countries, with PageControl, on every page you can place TableGrid with enabled option
Editable > AllowCreate = True and Editable > AllowEdit = True
for each database table.

Dmitry.

17 (edited by dbk 2018-11-30 20:03:58)

Re: unbound dropbox list

DriveSoft wrote:

Yes, sometime it's tedious, but it's right way.


You can create one form for data like Gender or Countries, with PageControl, on every page you can place TableGrid with enabled option
Editable > AllowCreate = True and Editable > AllowEdit = True
for each database table.

Hello Dmitry,

Ok, i will do it like this. Thank you for the tip with the editable grids, this actually makes it a lot quicker and easier than designing all kinds of forms to fill in the data. Thanks!