×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to Add combo box inside grid
3

How to Add combo box inside grid

How to Add combo box inside grid

(OP)
I have a grid as Grid1 and the columns are as below.

CODE

Code    Qty          Delivery MODE
520B    100        
521B    300        
522B    500 


I want to add a combo box to the Delivery MODE column to select one value from the Delivery MODE list. How can I do this? please assist me..
Thank you 

RE: How to Add combo box inside grid

I assume you want to do this at design time? If so, follow these steps:

1. In the Form Designer, right-click on the grid, and choose Edit.

2. Click in the Delivery Mode column (the column itself, not the header). You should now see the name of that column in the drop-down list at the top of the Properties window.

3. Select a combo box from the form designer's toolbar, or the Project Manager window, or the Toolbox, or whatever. Drop it in the column.

4. Nothing seems to have happened. In fact, the combo box has been successfully added, but it is obscured by the existing textbox, which is still present. (You can confirm this by looking at the drop-down list at the top of the Properties window.)

5. So, the next step is to remove the textbox: Select the textbox in the drop-down list at the top of the Properties window. Be sure that it's the textbox in the column which also has the combo box.

6. Click on the title bar of the Form Designer (not on the form itself; if you do, you will de-select the combo box). Press the Del key.

You should now see the combo box in the column in the form designer.

When you run the grid, you will only see the combo in the row that has focus, which is probably what you want. But if you want to see the combo in every row at the same time, then set the columns Sparse property to .F.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: How to Add combo box inside grid

I find it easier to add the control you want in the grid to the form itself first, as described by chpicker in thread184-230247: Add control to grid
Otherwise Mike has described the necessity to choose sparse or not. But removing the textbox is optional, so steps 5 and 6 in Mikes description are not mandatory, you can do something else, you can set the column currentcontrol to the combobox.

There's another complication to solve, if you decide to only show the combo in the active row of the grid, the other rows will show their textbox. Indeed it won't matter if you remove the default text1 textbox of the column or keep it in, in sparse mode the rows besides the active row will show a textbox. And that will not necessarily be able to show the selection you made in the combobox. That will depend on the controlsource you set up in the combo. If that's the key of a record of a table of delivery modes, and the combo is set to display the column with the delivery mode as text, the other rows will show the key, though, not the text.

The next topic will be how to design the combobox so it's compatible for grid usage. As the grid has to have a recordsource and in that deliver mode column has to have a controlsource of the delivermode text or key. That controlsource also has to be the controlsource of the combobox, but you can't make the delivery mode text a controlsource to a list of delivery mode texts.

Now there are several ways out of this dilemma, but the simplest is to set the column to not be sparse and instead show the combobox in every row, also the non-active rows, which means the combo will display the selection made on each row, also when you leave the rows.

The combobox in every row isn't very esthetic design, but it's just a matter of taste.

All in all, let this just be a warning that overcoming the problem to just add the combobox into the grid, it's not the last hard problem about the construct of a grid also usable for entering data, even just in your still quite simple case of picking a mode.

Chriss

RE: How to Add combo box inside grid

Just want to point out that the easiest way to add controls to grid columns is with the Toolbox. Just drag the class you want and drop it on the column.

Tamar

RE: How to Add combo box inside grid

But, Tamar, don't you still have to put the grid in edit mode first? And don't you still have to either remove the existing text box or set the combo as the current control? If so, the steps I outlined would still be relevant.

I might well be wrong about this. I am quite ignorant of the Toolbox.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: How to Add combo box inside grid

Nope, the Toolbox handles all that. It's really well-designed for this. It has an option that let you decide whether the control you drop replaces Text1 or is in addition.

The Toolbox is incredibly cool and after using it for a lot of years, I wouldn't want to have to add controls to forms any other way. Here's my paper on why people should use the Toolbox: http://tomorrowssolutionsllc.com/ConferenceSession...

Tamar

RE: How to Add combo box inside grid

Quote:

It has an option that let you decide whether the control you drop replaces Text1 or is in addition.

I didn't know that. A very useful feature.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: How to Add combo box inside grid

The Toolbox is really awesome. Before it shipped, I didn't like any of the options for putting controls on forms. They all seemed clunky and annoying.

Tamar

RE: How to Add combo box inside grid

Tamar, I didn't know that the toolbox is so feature rich. Thank you for sharing!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close