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

Grid and buttons ... 3

Status
Not open for further replies.

ShyFox

Programmer
Mar 22, 2003
210
ES
hy,
I have a grid and I want to put a button in every cell of the collumn SCRAP that will open a form and let the operators to choose some values.
I indeed insert the button but it covers all the cell. I want to look like the below graphic:
_____________________________
| ________ |
| [_Button_] Text of the cell |
|_____________________________|

Regards

As I go deeper the road seems to go further. We're just simply pasangers on the road of knowledge.
 
ShyFox

Save a container as a class and resize to fit column.

Add a commandbutton and label if required to the container class and resize commandbutton and label.

Add the container class to the column.

Remove the textbox from the column.

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Chris & Mike
Thank you.
This is my code:

Public oform1
oform1=Newobject("form1")
oform1.AddObject("grid1","grid1")
oform1.grid1.column1.Sparse = .F.
oform1.grid1.column2.Sparse = .F.
oform1.grid1.column1.Width = 200
oform1.grid1.column2.Width = 150
oform1.Show
Return
Define Class form1 As Form
Top = 4
Left = -1
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
Procedure Load
Create Cursor myCursor (Name c(10))
Insert Into myCursor (Name) VALUES ("Mike")
Insert Into myCursor (Name) VALUES ("Chris")
Insert Into myCursor (Name) VALUES ("Shankel")
Insert Into myCursor (Name) VALUES ("TheHulk")
Insert Into myCursor (Name) VALUES ("Archangel")
Insert Into myCursor (Name) VALUES ("Sheylak")
Insert Into myCursor (Name) VALUES ("Hamnoc")
Go Top
Endproc
Enddefine
Define Class grid1 As Grid
ColumnCount =2
RowHeight = 20
Visible = .T.
Height = 220
Procedure Init
With This
.column1.AddObject("TextB_CommB","TextB_CommB")
.column1.CurrentControl="TextB_CommB"
.column1.TextB_CommB.text1.ControlSource="myCursor.name"
Endwith
Endproc
Enddefine
Define Class TextB_CommB As Container
Width = 350
Height = 40
Name = "TextB_CommB"
Visible = .T.
Add Object text1 As TextBox With ;
Height = 23, ;
Left = 0, ;
Top = 0, ;
Width = 160, ;
Name = "Text1",;
visible = .T.
Add Object Cauta As CommandButton WITH ;
Height = 23,;
Left = 160,;
Top = 0,;
Width = 40,;
Name = "Command",;
visible = .T.
Enddefine

But ... I would like that when I drag the column that has the textbox and the buton to increase the width of the textbox and position the buton acordingly.
Is there a posibility to achieve that?
Regards

As I go deeper the road seems to go further. We're just simply pasangers on the road of knowledge.
 
Shyfox,

Public oform1
oform1=Newobject("form1")
oform1.AddObject("grid1","grid1")
oform1.grid1.column1.Sparse = .F.
oform1.grid1.column2.Sparse = .F.
oform1.grid1.column1.Width = 200
oform1.grid1.column2.Width = 150
oform1.Show
Return
Define Class form1 As Form
Top = 4
Left = -1
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
Procedure Load
Create Cursor myCursor (Name c(10))
Insert Into myCursor (Name) VALUES ("Mike")
Insert Into myCursor (Name) VALUES ("Chris")
Insert Into myCursor (Name) VALUES ("Shankel")
Insert Into myCursor (Name) VALUES ("TheHulk")
Insert Into myCursor (Name) VALUES ("Archangel")
Insert Into myCursor (Name) VALUES ("Sheylak")
Insert Into myCursor (Name) VALUES ("Hamnoc")
Go Top
Endproc
Enddefine
Define Class grid1 As Grid
ColumnCount =2
RowHeight = 23
Visible = .T.
Height = 220
Procedure Init
With This
.column1.AddObject("TextB_CommB","TextB_CommB")
.column1.CurrentControl="TextB_CommB"
.column1.TextB_CommB.text1.ControlSource="myCursor.name"
ENDWITH
ENDPROC
PROCEDURE column1.resize
LOCAL nValue
nValue = this.Width - this.TextB_CommB.command.width
this.TextB_CommB.width = this.Width
this.TextB_CommB.command.left = nValue
this.TextB_CommB.Text1.width = nValue
ENDPROC
Enddefine
Define Class TextB_CommB As Container
Width = 350
Height = 40
Name = "TextB_CommB"
Visible = .T.
Add Object text1 As TextBox With ;
Height = 23, ;
Left = 0, ;
Top = 0, ;
Width = 160, ;
Name = "Text1",;
visible = .T.
Add Object Cauta As CommandButton WITH ;
Height = 23,;
Left = 160,;
Top = 0,;
Width = 40,;
Name = "Command",;
visible = .T.
Enddefine

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
slighthaze (IS/IT--Manageme)
Star for you. You deserve it.
Thank you
Regards

As I go deeper the road seems to go further. We're just simply pasangers on the road of knowledge.
 
Thanks to Slighthaze, Chris & Mike ideea moved on as you can see below.


************************************************************
Public oform1
oform1=Newobject("form1")
oform1.AddObject("grid1","grid1")
oform1.grid1.column1.Sparse = .F.
oform1.grid1.column2.Sparse = .F.
oform1.grid1.column1.Width = 200
oform1.grid1.column2.Width = 200
oform1.Show
RETURN
************************************************************
Define Class form1 As Form
Top = 4
Left = -1
DoCreate = .T.
Caption = "Grid cu butoane . . ."
Name = "Form1"
width = 700
Procedure Load
Create Cursor myCursor (Name c(10))
Insert Into myCursor (Name) VALUES ("Mike")
Insert Into myCursor (Name) VALUES ("Chris")
Insert Into myCursor (Name) VALUES ("Shankel")
Insert Into myCursor (Name) VALUES ("TheHulk")
Insert Into myCursor (Name) VALUES ("Archangel")
Insert Into myCursor (Name) VALUES ("Sheylak")
Insert Into myCursor (Name) VALUES ("Hamnoc")
Go Top
ENDPROC
ENDDEFINE
************************************************************
Define Class grid1 As Grid
ColumnCount =2
RowHeight = 23
Visible = .T.
Height = 220
width = 500
Procedure Init
With This
.AllowRowSizing = .F.
.column1.AddObject("TextB_CommB","TextB_CommB")
.column1.CurrentControl="TextB_CommB"
.column1.TextB_CommB.text1.ControlSource="myCursor.name"
ENDWITH
ENDPROC
PROCEDURE column1.resize
LOCAL nValue
nValue = this.Width - this.TextB_CommB.command.width
this.TextB_CommB.width = this.Width
this.TextB_CommB.command.left = nValue
this.TextB_CommB.Text1.width = nValue
ENDPROC
Enddefine
************************************************************
Define Class TextB_CommB As Container
Width = 350
Height = 40
Name = "TextB_CommB"
Visible = .T.
BackColor = RGB(255,255,255)
Add Object text1 As TextBox With ;
Height = 23, ;
Left = 0, ;
Top = 0, ;
Width = 180, ;
Name = "Text1",;
SpecialEffect = 1, ;
BorderColor = RGB(255,255,255), ;
visible = .T.
Add Object Command As CommandButton WITH ;
Height = 23,;
Left = 180,;
Top = 0,;
Width = 20,;
Name = "Command",;
SpecialEffect = 0,;
Caption = "...",;
visible = .T.
PROCEDURE Command.Click
do form options.scx
ENDPROC
Enddefine

Once again I need your help:
Indeed my "options.scx" form apears but I don't know how can I move all the data that I wrote or/and choosed from the "options.scx" into the textbox situated that is situated near the button I pushed.
I think is something of reference from "options.scx" to the principal form that has the grid. But I don't know how to refer to form properties and/or objects situated on it from another form. Only the formset gave me this oportunity before. But I don't use it anymore, so does anybody have an ideea?
Regards

As I go deeper the road seems to go further. We're just simply pasangers on the road of knowledge.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top