Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a Combobox to a grid 1

Status
Not open for further replies.

Brenton

Technical User
Jul 29, 2002
43
US
I have searched through the archives and FAQ's and found some help that left me more confused than anything. I have a form with a grid on it. I want to change one of the columns from a textbox to a combo box, and fill the box with a certain feild in a table. So far I have had no luck, but hopefully I explained myself good enough for someone to be able to help me.

 
Brenton

[ol][li]Modify your form.[/li]
[li]Bring the property sheet.[/li]
[li]Get to the property of the column you wan to add the combo to.[/li]
[li]With the property sheet still opened, drag the comboboc from the form controls, hold the left mouse down and drag&drop it on the column of the grid.[/li]
[li]Change the CurrentControl of the grid to the combobox[/li]
[li]You may want to put the column's sparse property to false.[/li][/lo]


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I don't think i am following you. I created a new combobox on my form. Then I opened up the properties for my grid and tried to drag my combobox from my form to my grid column8 properties. I can't drag anything off of my form. I guess its fair to say I am Lost.

 
Brenton

4. With the property sheet still opened, drag the combobox from the form controls, hold the left mouse down and drag&drop it on the column of the grid.

I meant that you drag the combo from the Form Control Toolbar (the one that hold all the different controls you can place on a form).





Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
When you say property sheet are you talking about the properties window?

 
Mike - is this like adding a Checkbox to a grid, where in addition to adding the new OLE object (e.g. checkbox) you also have to Delete the Column's default Textbox to get it to work?

I_Forgot
 
IFORGOT

you also have to Delete the Column's default Textbox to get it to work?

I'm sorry, but I disagree. I have a grid column that holds three controls including the original textbox , so I can switch between them depending on the condition. I actually never remove the original textbox, a grid column can have many different controls in it (Including an actual form!).

Brenton

When you say property sheet are you talking about the properties window?

That is correct.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
My form Controls Toolbar will not let me drag anything off of it.
 
Or you can do it programatically in the INIT event:

WITH thisform.grid1
.column4.removeobject("Text1")
.column4.addobject("ControlName","combobox")
.column4.CurrentControl="ControlName"
.column4.ControlName.rowsource="A,B,C"
.column4.ControlName.rowsourcetype=1
.column4.ControlName.style=2
.column4.controlsource="MyTable.FieldName"
.column4.ControlName.boundto=.t.
.column4.ControlName.value=lcRpttypeVal
.RowHeight=21
ENDWITH

Brian
 
Brenton

Just do as you normally would to put a control on a form, this time just put it directly on the column of your grid (with the property window opened to the correct column)

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
OK...I got the combo box onto the grid. Thank you very much mgagnon. Now how do I make use of the new combobox? I used
grid1.column8.text1.visible=.f.
grid1.column8.combo1.visible=.t.

but nothing seems to change.
 
Brenton

As stated in my first suggestion:

Change the CurrentControl of the grid to the combobox



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
That Did it for me. Thank you very much for all your help mgagnon.

 
Brenton

Thank you very much for all your help mgagnon.

Your welcome. You just need to set your control source and rowsource.
Unfortunately this is one instance the describing a process is very difficult on a forum like this. Visually is easier.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top