Paramu


Hi There,

Actually I have a Grid containing 2-columns, and through the Add Object Method, I added the
object of Combobox to the grid [column1]. Also the Combobox is having 2-columns...datas from
table.

When I click the 1st column of grid the combo box is acting properly..

My requirement is, If I select the First column of combobox, The First column data
is replacing to column1 of grid automatically, but the second column of combobox
data also need to replace the column2 of grid...at the time of selection it self..
for that anyone to help me please....

Above From...Paramu





Re: Little Doubt with Grids

Markish


Hi Paramu,

I think the best way is to update the content of the cursor / table whatsover is the recordsource for the grid based on the selection made on the grid. You can add some code to update the table (grid recordsource) in the valid event of the combobox. Hope this solves your problem.

(But can you please let us know the scenario of this. I've never did like this before. Probably I can use it if it's useful...)

Best regards,

Markish







Re: Little Doubt with Grids

Paramu


Yah Mr.Markish,

Well. Thanks for Your Kind Immediate Reply...Also sorry for my delay

As per my experience the Grid control is good for Entry Screen to user....


My Codings...

***************************************************************

In the Entry Button...
--------------------

thisform.grid1.column1.AddObject('Comb1','Combobox')

SELECT 5
GO top
thisform.grid1.column1.Comb1.ColumnCount=2
thisform.grid1.column1.Comb1.ColumnWidths = "25,150"
r=0
DO WHILE .not. EOF()
r=r+1
thisform.grid1.column1.Comb1.addlistitem(item_code,r,1)
thisform.grid1.column1.Comb1.addlistitem(item_descr,r,2)
SKIP
enddo
thisform.grid1.column1.Comb1.FontName = "Times New Roman"
thisform.grid1.column1.Comb1.FontSize =8


thisform.grid1.column1.CurrentControl ='Comb1'

***************************************************************

After running the form, when I click the first column of Grid,the combo box
will activate ...and after my selection of combobox the first
column data of Combo box will replace to the grid-table automattically...

And I need when I select 1st column of combo box , the 2nd column data also
need to replace to 2column of grid....

Really this way is good for Users to feed datas ..

by PARAMU







Re: Little Doubt with Grids

Markish

Hi Paramu,

I got this. Still what are you showing in the grid and combo. Is it the data from the same table. Are the columns bound to data..

In any case you need to update the table underlying the grid (recordsource).

Best regards,

Markish






Re: Little Doubt with Grids

Paramu

Hi Markish,

Well. But those are different tables...






Re: Little Doubt with Grids

Paramu






Re: Little Doubt with Grids

Markish

Hi Paramu,

In the valid event of the combo you add some code like

Code Snippet

sele grd_rec_source

repl field2 with combo_source.field2

thisform.refresh

This would do I suppose. But seeing your code I have few comments

  • Instead of adding the combobox at runtime you can add it in the designtime of the form and set its rowsource and rowsourcetype, so that you can add code to it's valid event
  • If you use rowsourcetype as alias and rowsource as some cursor, you can easily replace the grd_rec_source (table I suppose) as I 've told above

Best regards,

Markish






Re: Little Doubt with Grids

Paramu

Yah Mr.Markish,

Well. But adding in runtime is good for Screening...Suppose if you want to access through different models of system means ...I mean some one by laptop, another by desktop, and for these type users can get proper screen by just

run time adding...[anchor -property]...

So give me an idea at runtime....from combobox to grid columns....

by PARAMU






Re: Little Doubt with Grids

Markish

Hi Paramu,

You can then use "Bindevent" if you prefer runtime.






Re: Little Doubt with Grids

CetinBasoz

Public oForm

oForm = Createobject('myForm')

oForm.Show()

Define Class myForm As Form

DataSession = 2

Add Object myGrid As Grid

Procedure Load

USE products IN 0

Select product_id From orditems Into Cursor myTestCursor Readwrite

Endproc

Procedure Init

With This.myGrid

.ColumnCount = 2

.RowHeight = 25

With .Columns(1)

.AddObject('myCombo','Combobox')

.CurrentControl = 'myCombo'

.myCombo.RowSourceType = 6

.myCombo.RowSource = 'products.product_id,prod_name'

.myCombo.ColumnCount = 2

.myCombo.ColumnWidths = "50,100"

.myCombo.Visible = .T.

Endwith

.Columns(2).ControlSource = ;

"(IIF(SEEK(product_id,'products','product_id'),Products.Prod_Name,''))"

Endwith

Endproc

Enddefine





Re: Little Doubt with Grids

Paramu

Thanks to both replies...[ Markish & CetinBasoz]

With Regards...PARAMU






Re: Little Doubt with Grids

Paramu

Thanks To Markish & CetinBasoz

Wirh Regards..PARAMU






Re: Little Doubt with Grids

Paramu

Hi CetinBasoz,

Pls...sorry to disturb you....

can you pls...explain me the following....

Table1- Fields[product_id,Product_name] available in combo box

Table2-Fields[Item_id,Item_name] available in grid box...

In grid box...column1 accessing combo box...

so can you pls... give me the exact coding for

colums(2).controlsource....

"(iif(seek())........

Once again sorry if anything got disturbances..

By PARAMU






Re: Little Doubt with Grids

CetinBasoz

Columns(2) is a calculated column with that expression. It does a seek of product_id selected in its base table products. If found then returning the prod_name value else an empty string.





Re: Little Doubt with Grids

Paramu

Once again Thank You CetinBasoz.... I hope this time I will succeed......

Wirh Regards....PARAMU