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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two Control in a Grid Column 5

Status
Not open for further replies.

abbasaif

ISP
Oct 8, 2018
89
0
0
AE
Hi,

Can I use two controls in a grid column as shown in image.
Combo and Textbox for different rows.

Please advise.

Thanks

Abbasaif

grdcontrol_iadngt.jpg
 
For the moment.

Is it always '1', '2', '3', and '10'?

Yes,

All the format is fixed, except the last column "Acceptance". There would be no changes in Sr.No. (Sno).

I think, it is because of '1' which contain in 10,11,12,13, 14 and 15.

Abbasaif
 
This will do:
Code:
THIS.Column4.DynamicCurrentControl = "IIF(INLIST(JobRoll.Sno, '1 ', '2 ', '3 ', '10 '), 'Combo1', 'Text1')"

If Sno is C(2), then you can and need to use '10', but overall if your Sno actually is a string that actually is a number, I assume it will be C(11) at least to have a larger range than integers. It's useless most of the time, as DBFs will never allow you to have more than 2GB/recsize() rows, which even for 1 byte short records is never exceeding 2 billion.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Thanks Mike, I put set exact on and the matter is solved.

How can I define the value for combo box like;

1. for sno=1 value should be "Inside/Outside"
2. for sno=2 value should be "Reverse/Surface"
3. for sno=4 value should be "Ok/Not Ok" (Sorry I mentioned Sno=3)

and so on

How can I do so?

Abbasaif
 
Thanks Mr. Olaf for

THIS.Column4.DynamicCurrentControl = "IIF(INLIST(JobRoll.Sno, '1 ', '2 ', '3 ', '10 '), 'Combo1', 'Text1')"

Abbasaif
 
>I put set exact on and the matter is solved.

Well, you very likely use the inexact string matching nature of VFP even completely unintentional, I'd keep it off and solve it in other ways, ie with adding trailing spaces in the comparison values.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf said:
you very likely use the inexact string matching nature of VFP even completely unintentional, I'd keep it off and solve it in other ways, ie with adding trailing spaces in the comparison values.

I completely agree. If Sno can go up to 99, then you should be comparing it with a two-character string. If values below 10 contain a leading space, then compare it with, for example, [tt]' 9'[/tt] (that's a space followed by a digit). If the field has a trailing space, then comapre it with [tt]'9 '[/tt] (digit then space).

Better still, avoid all these problems by storing the field as a numeric.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi,

You mean to say to I should do like this;


THIS.Column4.DynamicCurrentControl = ;
"IIF(INLIST(Job.Roll.Sno, '1 ', '2 ', '3 ', '10'), 'combo1', 'text1')"

As the length of sno is greater than 3 digit. But not I have altered with 3 digits.
I will change the field from character to numeric.

Thanks

( I will put the set exact off again ).

Abbasaif
 
Also, please let me know how to assign the values of combo box as follows:

1. for sno=1 value should be "Inside/Outside"
2. for sno=2 value should be "Reverse/Surface"
3. for sno=4 value should be "Ok/Not Ok" (Sorry I mentioned Sno=3)

and so on

Abbasaif
 
The simplest way to desing a comboboc is using Rowsroucetype 1 (values) and set the value to a comma separated list of values, that map to 1 = first entry, 2= second entry etc.

Other ways exsist. Simply read in your foxpro reference on how to use a combobox. The hackers guide may be simpler to get than the VFP help and have more examples.
But a search here will also surely give you mane examples on how to populate and use a combobox.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hi

I tried to get value for combo box in column4 based on the value of column1.text ( Sno = '1')
Please look into the image.

The value is coming correct. i.e, Inside/Outside, but for 2nd column I want Reverse/Surface but it is not showing and accumulate the first row value for the combo of 2nd row.

I am using this code in the got focus event of the combo in column4.

Code:
Do Case
Case This.Parent.Parent.Column1.Text1.Value = '1 '
   This.AddItem("Inside")
   This.AddItem("Outside")
Case This.Parent.Parent.Column1.Text1.Value = '2 '
   This.AddItem("Reverse")
   This.AddItem("Surface")
Case This.Parent.Parent.Column1.Text1.Value = '4 '
Case This.Parent.Parent.Column1.Text1.Value = '10'
Endcase

grd2_m2zagf.jpg

grd3_fftaon.jpg
 
Only addd items once in the combobox initialisation, or you get repeated items every time you click on the grid.

If you want to populate the comboobx with different items per grid row, then you first need to clear it.

A good events for that would be Grid.AfterRowColChange so you are in the current row.

Then never read from grid control.value properties, you bind the grid to workarea columns, so address JobRoll.Snom not Column1.Text1.Valu
There only is one Column1.Text1.Value and depending on when and where you read that, this will not be the value of the current row.

Bye, Olaf.

Olaf Doschke Software Engineering
 
And the biggest thing you should do: VFP is data oriented, isn't it? If the combobox items depend on the Sno, then define a table holding the combobox items as comboitems(Sno, item, itemorder) and set the items by [tt]SELECT * FROM combo WHERE comboitemsSno=JobRoll.Sno ORDER BY itemorder[/tt].

Don't write out a bid case statement that's actuelly encoding just data, use data for data.

Bye, Olaf.



Olaf Doschke Software Engineering
 
And one more thing: If Sno determines an item list for the comobobox, you also need something else to store the picked value. So Acceptance should be a field that stored the item number of the picked item and in turn also determines which item is shown. That's the combobox.controlsource.

Otherwise you have picklists but every combo will show its first item and then the picked item is not recorded anywhere.

When you're finally there you'll also notice that an Acceptance field will have the same value, say 2 for second item, even when due to different Sno you show different item lists. So only the combination of Sno and Acceptance value will in combinatin point to the one picked comboitem of the table I suggested for sno=jobroll.sno and itemorder=JobRoll.acceptance. Whether that's a good idea, I don't know, I'd rather want a simple foreign key that directly points to the item actually picked.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top