Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Cecil Champenois
  Where is Cecil Champenois?
 Little Elm
 Texas - United States
 Cecil Champenois
 Tags
Subject: RE: Binding a field to a DropDown List
Thread ID: 248759 Message ID: 248776 # Views: 3 # Ratings: 1
Version: Visual FoxPro 9 SP2 Category: Forms
Date: Wednesday, December 23, 2009 10:22:32 AM         
   


> I have normally set up a dropdown list box by making an array from a picklist table. I liek thsi way fo doign it.
>

IMO, combo.RowsourceType=5 is indeed a good one. A big advantage is that you do not to care for any cursors/aliases in the current data session, so that the combo-box can be somewhat autonomously "encapsulated", e.g. you cannot get the infamous Error 1152.

> But, I am a little confused as to how you bind that DropDown List to the specific data that the user selects from the list, or maybe my question is how does this work? Iv'e got it workign on several forms, but when I tried to implement it on another form, it doesn't seem to be bound to the data.
>
> Here's what I have set in the Properties of the DropDown List box: (This one works just fine)
>
> The name of the control is cboMill.
>
> BoundColumn = 2
> BoundTo = .T.
> RowSource = ThisForm.aMills
> RowSourceType = 5 (Array)
> Style = 2 (DropDown List)
>
> In the Control's INIT:
> cboMill = "This.ListIndex = 1"
>
> In the FORM's INIT:
> ThisForm.cboMill.ControlSource="Certs.Mill_ID" <<--- (This is what I think I forgot to add.)
>
> I sometimes wonder why we cannot set the SourceControl on the DropDownList object? Why is it that we have to set thsi manually in the FORM"s INIT, rather than in the control itself? Or, am I mistaken?
>

You can indeed set combo.ControlSource earlier, especially if you keep all in one place.
In your description above, the settings are a little spread over the place - i.e. a Form.customArray property is an "external" thing from the Control's point-of-view, and using it as the Control.RowSource gives a timing problem, because form.Init() runs much later than control.Init() so that the combo has to wait a while.
IOW, I'd suggest not to use a Form.customArray but rather Control.customArray (that you can add in the Class Designer, or, if Combo does not have a ParentClass, by using This.AddProperty() in Combo.Init().



hth
-Stefan

ENTIRE THREAD

Binding a field to a DropDown List Posted by Cecil Champenois @ 12/23/2009 2:21:05 AM
RE: Binding a field to a DropDown List Posted by kulwant singh @ 12/23/2009 4:50:48 AM
RE: Binding a field to a DropDown List Posted by Stefan Wuebbe @ 12/23/2009 10:22:32 AM