Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Container object in a grid column
Message
From
09/05/2003 09:23:07
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
09/05/2003 08:52:40
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00786698
Message ID:
00786747
Views:
14
>>>>>I have a container class with a textbox and a command button in it. The textbox will contain a value returned from a search screen accessed by the command button. My problem is that when the column is resized, the containers Resize() event (where I have code that resizes the text box so that it fills the width of the column less the width of the button and the button stays "glued" to the right edge of the column) does not fire. Short of putting code in the columns Resize() event, is there any way to have the container resize just like any other control (ie: textbox, combobox) when the column is resized? BTW, why would the column not resize the container anyway?
>>>>>
>>>>>Thanks in advance for any help!
>>>>>
>>>>>Regards,
>>>>>
>>>>>Don
>>>>
>>>>Don,
>>>>Column.resize doesn't automatically invoke container.resize. Call explicitly from column.resize.
>>>>Cetin
>>>
>>>
>>>It appears that I cannot even do that. I beleive the containers Width property becomes ReadOnly in a grid column. Thanks anyway. Any other suggestions would be greatly appreciated.
>>>
>>>Don
>>
>>Oh my I didn't say touch width or height, explictly call resize :
>>
>>*Column.resize
>>this.myContainer.Resize()
>>
>>Cetin
>
>
>I have the following code in the columns Resize() event:
>
>
>*Column2.Resize() event code
>
>Local loCtl
>
>For Each loCtl In This.Controls
>	If loCtl.BaseClass = "Container" Then
>		loCtl.Resize()
>	EndIf
>Next loCtl
>
>
>
>*Container Resize() event code
>
>If This.Parent.Parent.RowHeight > 10 And This.Parent.Width > 10 Then
>	This.Width = This.Parent.Width
>	This.Height = This.Parent.Parent.RowHeight
>	
>	With This.cmdFindCustomer
>		.Top = 0
>		.Width = This.Height
>		.Height = This.Height
>		.Left = This.Width - This.Height
>	EndWith
>	
>	With This.txtCustomerName
>		.Top = 0
>		.Left = 0
>		.Height = This.Height
>		.Width = This.Width - This.Height
>	EndWith
>EndIf
>
>
>
>I stepped through it and when it got to the "This.Width = This.Parent.Width" line, the This.Width remained unchanged even though This.Parent.Width was much larger. It appears to me that a container cannot be resized when contained in a grid.
>
>Thanks for your help though, Cetin. I'm still open to any other ideas.
>
>Thanks in advance!
>
>Don

I don't knwo why not working for you. Tried a quick test and it worked :
Use customer
Public oForm
oForm = Createobject('Form')
oForm.Newobject('myGrid','Grid')
oForm.myGrid.RecordSource = 'customer'
oForm.myGrid.Newobject('NewColumn','myColumn')
oForm.myGrid.NewColumn.ColumnOrder = 1
oForm.myGrid.NewColumn.Resize()
oForm.SetAll('Visible',.T.)
oForm.Show


Define Class myColumn As Column
  Procedure Resize
    For Each loCtl In This.Controls
      If loCtl.BaseClass = "Container" Then
        loCtl.Resize()
      Endif
      loCtl = .Null.
    Next loCtl
    This.Refresh
  Endproc
  Procedure Init
    This.Newobject('myControl','myContainer')
    This.CurrentControl = 'myControl'
    This.Sparse = .F.
  Endproc
Enddefine

Define Class myContainer As Container
  Height = 20
  Width = 100
  Add Object cmdFindCustomer As CommandButton With Left = 60, Width=38, Caption='...'
  Add Object txtCustomerName As TextBox With Left = 2, Width = 50
  Procedure Resize
    If Type('This.Parent.Parent.RowHeight')='N' ;
        and This.Parent.Parent.RowHeight > 10 ;
        And This.Parent.Width > 10 Then
      Local lnWidth,lnHeight
      lnWidth = This.Parent.Width
      lnHeight = This.Parent.Parent.RowHeight
      This.Width = lnWidth
      This.Height = lnHeight

      With This.cmdFindCustomer
        .Top = 0
        .Width = lnHeight
        .Height = lnHeight
        .Left = lnWidth - .Width
      Endwith

      With This.txtCustomerName
        .Top = 0
        .Left = 0
        .Height = lnHeight
        .Width = lnWidth - lnHeight
      Endwith
    Endif
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform