Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Problem with TButtonComobox display
Wed, Aug 16 2017 2:46 PMPermanent Link

Richard Mace

I'm having an issue, manually adding items to a TButtonComboBox. As you can see from the first image, this is what I get when I add to the combo at run time. If I then click on it again, it displays correctly.

Any ideas?



Attachments: 20170816_154512.jpg
Wed, Aug 16 2017 3:01 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< I'm having an issue, manually adding items to a TButtonComboBox. As you can see from the first image, this is what I get when I add to the combo at run time. If I then click on it again, it displays correctly. >>

Where/when exactly are you adding the items ?  Please post some code to indicate how you're doing this at run-time.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Aug 17 2017 2:11 AMPermanent Link

Richard Mace

Tim Young [Elevate Software] wrote:

<< Where/when exactly are you adding the items ?  Please post some code to indicate how you're doing this at run-time.>>

OK, so the form that contains the combo is being created manually within the main forms create event:

 frmJobProperties := TfrmJobProperties.Create(nil);
 frmJobProperties.Hide;

and then in the JobFormProperties form, in the ShowModal, I have some code that retrieves some "Agents" from the EDB, and then on the returned event, I have the code to add them to the combo box:

 cboAgentAssignedTo.Items.Clear;
 for I := 0 to ffrmDBase.AllAgents.Count -1 do
   begin
     fAgentsSL.Add(IntToStr(ffrmDBase.AllAgents.Items[I].Id));
     cboAgentAssignedTo.Items.Add(ffrmDBase.AllAgents.Items[I].AgentName);
   end;

The fAgentsSL is a StringLlist, just for keeping track of the AgentsId.

Another thing that might be worth mentioning, is that I have my own ShowModalX for passing parameters in, and then I call ShowModal to display the form.

Richard
Thu, Aug 17 2017 7:37 AMPermanent Link

Walter Matte

Tactical Business Corporation



What is the variable AllAgents - what is it defined as?

Understood - combobox.add.item - we know the method used to add the items - I think Tim's question was more along the lines of timing - when are you doing this - what event or function call is invoking the item.add ?

More code around the flow is needed.

FYI I use Application not Nil when creating forms in runtime.

TfrmJobProperties.Create(nil)  ->  TfrmJobProperties.Create(Application)

Just another thought - instead of your own ShowModalX - have property variables.  
- Create the Form
- Set the properties - then in the setter you can initialize the comboboxes
- Call Show or ShwoModal

Walter
Thu, Aug 17 2017 7:39 AMPermanent Link

Matthew Jones

Richard Mace wrote:

> OK, so the form that contains the combo is being created manually within the main forms create event:
>
>   frmJobProperties := TfrmJobProperties.Create(nil);
>   frmJobProperties.Hide;

I think you should pass Application as the owner. And why not just have the form set with Visible = false in the IDE so you don't have to manually hide it?


> and then in the JobFormProperties form, in the ShowModal, I have some code that retrieves some "Agents" from the EDB, and then on the returned event

That will be the problem - the return is not happening properly - either you are doing it too early, or not calling it.

FWIW, I use a DebugReport("message") routine which puts the messages into a multi-line edit which is normally invisible. This allows me to see the sequence of what is happening and when. (If you get into it, use a TStringList and then update occasionally from that, but I'm getting ahead of myself.)

--

Matthew Jones
Fri, Aug 18 2017 4:22 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< and then in the JobFormProperties form, in the ShowModal, I have some code that retrieves some "Agents" from the EDB, and then on the returned event, I have the code to add them to the combo box: >>

I'm with Matthew on this one.  If you're trying to load these after loading a dataset, then make sure that you've defined an event handler for the correct AfterLoad event for the dataset in question and make sure to call your drop-down loading code from there.

Tim Young
Elevate Software
www.elevatesoft.com
Image