Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using combo box in grid

2,033 views
Skip to first unread message

Hii Sing Chung

unread,
Oct 19, 2008, 4:10:34 AM10/19/08
to
Hi,

Is it possible to use combo box inside a grid, for selected columns? The
reason is I wanted to limit the user to the number of possible value that
the user can choose, therefore fixing the value for selected columns to only
what are defined. For example, for the field length, I only want the user to
be able to enter these values: 1016, 1064 and 1240.

Stefan Wuebbe

unread,
Oct 19, 2008, 6:59:59 AM10/19/08
to

"Hii Sing Chung" <sing...@hotmail.com> wrote in message
news:395FC56C-6341-4F39...@microsoft.com...
Hello,

Yes, you can actually add every VFP control class to a Grid.Column -
either programmatically at runtime, e.g. in yourGrid.Init():
With This.ColounX
.NewObject('Combo1','yourClass')
.Combo1.Visible = .T.
.CurrentControl = 'Combo1'
.Sparse = .F. && new control appears in every row at runtime
EndWith

or visually in the Form/Class Designer:
activate the desired form.grid.column in the Properties window
add your desired class from the Controls toolbar
modify column.CurrentControl
optionally set column.Sparse

FWIW, in my experience, Comboboxes inside Grids work best with
a cursor-less RowSourceType like 5 or 0 or 1


hth
-Stefan

--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------

Hii Sing Chung

unread,
Oct 19, 2008, 10:28:02 PM10/19/08
to
Thank you so much.
Just now when at design time, I added combo controls into the column1 and
because it is not visible on the screen (because the column.current control
not yet set?), so I thought it wasn't successfully added, then I tried 2
more times, not visible on the screen. When I look at the properties I found
3 combo controls under column1, now how do I remove the unwanted controls?
Another question is how do I set the combobox so that user can only choose
the values populated inside the combobox and not allow keying-in on the
textbox portion of the combobox, or must I only use listbox?

"Stefan Wuebbe" <stefan...@gmx.de> wrote in message
news:e6NswndM...@TK2MSFTNGP04.phx.gbl...

Rush Strong

unread,
Oct 20, 2008, 12:17:09 AM10/20/08
to

It's a little tricky:

- Select the unwanted control in the properties window;
- click on the top border (the title area) of the form; and
- press the Delete key.

A combo box is a list box which allows text entry. If you want to
block text entry, use a list box.

- Rush

Hii Sing Chung

unread,
Oct 20, 2008, 1:56:28 AM10/20/08
to
Rush,

I am so sorry, Foxpro is like a stranger to me.
When I used a listbox, these are the problems I faced: a. The height of the
listbox is confined to the height of the row in the grid, thus not able to
achieve the result of a 'drop-down' where I can see the list and choose
among the items. b. when i choose any item in the list and move to the next
field, the selected item isn't displayed in the listbox's column. For
example, in the grid I have column1 for productcode, column2 for
productdescription, column3 for thickness, column4 for width, column5 for
length, etc. The listbox I put under column1, when I select a productcode
from the list and move to column2, I expect the productcode to display at
column1's field. When I did this, the field is still blank.

Another question I would like to ask is how do I get the fields in other
columns being automatically entered when I choose the productcode in
column1. For example, if I choose a productcode called PP20, the column2's
field auto display "Polypropylene 20micron" (the productcode and description
are 2 columns in the product table, so whenever I choose a productcode I
want the corresponding descriptionto be automatically entered in column2),
the column3 display 20. Oh yes, how to extract the 3rd and 4th character
from column1 current productcode and assign it to column3, something like
the Instr in visual basic?

"Rush Strong" <rush.strong@[DELETEME]verizon.net> wrote in message
news:ed9o4qmM...@TK2MSFTNGP02.phx.gbl...

Stefan Wuebbe

unread,
Oct 20, 2008, 5:15:10 AM10/20/08
to

"Hii Sing Chung" <sing...@hotmail.com> schrieb im Newsbeitrag
news:E9D117E6-8B87-40F4...@microsoft.com...

> Thank you so much.
> Just now when at design time, I added combo controls into the column1 and because it is
> not visible on the screen (because the column.current control not yet set?), so I
> thought it wasn't successfully added, then I tried 2 more times, not visible on the
> screen. When I look at the properties I found 3 combo controls under column1, now how do
> I remove the unwanted controls?

You are welcome. As Rush already said, you can activate the control
you want to remove in the Properties window and then activate the
Form Designer window's tiltlebar and hit the <Del> key.

> Another question is how do I set the combobox so that user can only choose the values
> populated inside the combobox and not allow keying-in on the textbox portion of the
> combobox, or must I only use listbox?

Does combo.Style=2 do what you want?

Olaf Doschke

unread,
Oct 23, 2008, 2:06:43 PM10/23/08
to
Rush is wrong here.

As Stefan said, Style = 2 in a combobox gives
you a dropdown list instead of a combo, so
you can only choose from the list, not type.

Bye, Olaf.


Rush Strong

unread,
Oct 23, 2008, 2:24:35 PM10/23/08
to
Mea culpa - and I knew that, too. (Or at least I used to).

- Rush

0 new messages