[Gambas-user] Howto move a textbox over the column of the columnview control?
Ron Onstenk
ronstk at ...239...
Tue Nov 2 22:53:10 CET 2004
On Tuesday 02 November 2004 19:22, Wsouzap at ...87... wrote:
> MIME-Version: 1.0
> Message-ID: <71B0146C.03A923E6.001B903D at ...87...>
> X-Mailer: Atlas Mailer 2.0
> X-AOL-IP: 200.141.87.133
> X-AOL-Language: portuguese
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: 8bit
>
> Hi!
>
> Howto move a textbox over the column of the columnview control?
> I look the gambas IDE project in property form and the control is gridview. I'm need this effect in columnview control.
>
> Reguards,
>
> Wellington
>
I did it with tableview but columnview is more or less the same,
in fact the code is developed with it.
This code are part of a program I made and will not be complete
or run for you situation but it is the global way/idea to help you.
On the click or double click you get the row and column numbers
Basic then you call subroutine 'FldInput_DoPosit(row AS Integer,col AS Integer)'
After that is done you call a subroutine 'FldInput_DoFill(row AS Integer)'
to fill the control with data. In your case only the textbox
Set the control visible with FldInput_DoShowit(typ AS Integer)' where
typ in my case is the actual row also.
In my case the control changes for the row it is on may be you want
the column instead, same method to get the data and fill
'-----------------------------------------------------------
PRIVATE SUB FldInput_DoPosit(row AS Integer,col AS Integer)
DIM x AS Integer
DIM y AS Integer
DIM h AS Integer
DIM w AS Integer
DIM i AS Integer
DIM obj AS Object
obj=tableview1 '<--------- set to your columnview
currow=row '<---- global in module/class
curcol=col
x=obj.current.left '<-- get position actual col/row
x=x+obj.left
w=obj.current.width
IF obj.Border THEN x=x+1
y=obj.current.top
y=y+obj.top
h=obj.current.height
IF obj.Border THEN y=y+1
' i use combobox/textbox/checkbox/button etc
cbx.Clear ' <---i use combobox
cbx.Move(x,y,w,h-1)
TextBox1.Text=""
TextBox1.Move(x, y, w - btnProperty.W, h-2)
WITH btnProperty
.Move(x + w - .w ,y , 20, h-2)
END WITH
WITH chkVis
.Move (x + (w - .w)/2 , y + (h - .h)/2)
END WITH
WITH tableview1
IF currow<.rows.count AND curcol<.columns.count THEN
.MoveTo(currow,curcol)
ENDIF
END WITH
END
************************
the values enXXX are in real row positions
PUBLIC SUB FldInput_DoShowit(typ AS Integer)
TextArea2.visible=FALSE
TextBox1.Visible =FALSE
cbx.Visible =FALSE
chkVis.Visible =FALSE
btnProperty.Visible =FALSE
IF typ=enOFF THEN RETURN
IF typ=enVIS THEN
chkVis.Visible = TRUE
chkvis.raise()
chkVis.Setfocus()
ELSE
IF (typ<>enAS AND typ<>enWHR AND typ<enOR) THEN ' <> to <
cbx.Visible = TRUE
cbx.readonly=TRUE 'ne change event
cbx.raise()
cbx.Setfocus()
'keysend "F4" to open list part
ENDIF
IF (typ=enAS OR typ=enWHR OR typ>=enOR) THEN ' OR typ>enOR
btnProperty.Visible = TRUE
TextBox1.Visible = TRUE
TextBox1.Raise()
TextBox1.Setfocus()
ENDIF
ENDIF
END
***********************************************************
* The events fired on the temporary visible control
* (some debug code still in there)
***********************************************************
PUBLIC SUB TextBox1_LostFocus()
PRINT "TextBox1_LostFocus"
PRINT "key",Key.Code,Key.Shift
PRINT "ms",Key.Code,Key.Shift
CATCH
FldInput_Changed(TextBox1.Text)
END
PUBLIC SUB TextBox1_Change()
FldInput_Changed(TextBox1.Text)
END
PUBLIC SUB ComboBox1_Activate() 'Raised when the RETURN key is hit in the text box
'can not if readonly
PRINT "ComboBox1_Activate("
FldInput_Changed(ComboBox1.Text)
END
PUBLIC SUB ComboBox1_Change() 'Raised when the text in the combo box is modified
'not if readonly
PRINT "ComboBox1_Change("
FldInput_Changed(ComboBox1.Text)
END
PUBLIC SUB ComboBox1_Click() 'Raised when an element is selected in the popup list box
' if readonly and ??
PRINT "ComboBox1_Click"
FldInput_Changed(ComboBox1.Current.Text)
END
PUBLIC SUB chkVis_Click()
IF chkVIS.Value=0 THEN
FldInput_Changed("No")
ELSE
FldInput_Changed("Yes")
ENDIF
END
********************************************
* here you should put the value in your columnview
* my case the tableview source array
********************************************
PRIVATE SUB FldInput_Changed(txt AS String)
IF NOT cbxDoChange THEN RETURN
PRINT "FldInput_Changed",txt
IF curcol<0 OR currow<0 THEN RETURN 'failsafe
vArrSQL[curcol][currow]=txt
tableview1.refresh(currow,curcol)
END
********************************************
PRIVATE SUB FldInput_DoFill(row AS Integer)
DIM typ AS String
DIM i AS Integer
DIM coldat AS String[] 'Variant[]'
DIM stblfld AS String[]
DIM col AS Integer
col=curcol
IF row<0 OR col<0 THEN RETURN ' failsave
IF curcol>vArrSQL.count-1 THEN RETURN
coldat=vArrSQL[curcol]
cbxDoChange=FALSE
cbx.clear
cbx.Sorted =FALSE
cbx.Text=""
'project.rowhead=["tbl","fld","group","sort","visible","where"]
'this is also the row index sequence
SELECT CASE row
CASE enTBL
FldInput_TblUpdate()
cbx.Add("")
IF FldInput_Tables.Count>0 THEN ' the tables also on table pane
FldInput_Tables.Sort
FOR i= 0 TO FldInput_Tables.Count-1
cbx.Add(CStr(FldInput_Tables[i]))
NEXT
cbx.Text=coldat[enTBL]
ENDIF
CASE enFLD
IF coldat[enTBL]<>"" THEN
cbx.Add("")
IF Project.LBFS.LBframes.Exist(coldat[enTBL]) THEN
stblfld=Project.LBFS.LBframes[coldat[enTBL]].Fields
stblfld.Sort
IF stblfld.Count>0 THEN
cbx.Add("*")
FOR i= 0 TO stblfld.Count-1
cbx.Add(CStr(stblfld[i]))
NEXT
ENDIF 'stblfld.Count>0
cbx.Text=coldat[enFLD]
ENDIF 'exist
ELSE
coldat[enFLD]=""
ENDIF
CASE enAS
cbx.Text=coldat[enAS]
TextBox1.Text=coldat[enAS]
CASE enGRP
cbx.Add("")
FOR i = 0 TO grpfunc.Count-1
cbx.Add(grpfunc[i])
NEXT
cbx.Text=coldat[enGRP]
CASE enSRT
cbx.Add("(None)")
cbx.Add("Asc")
cbx.Add("Desc")
cbx.Text=coldat[enSRT]
CASE enVIS
chkVis.Value = If( coldat[enVIS]="Yes",TRUE,FALSE)
CASE enWHR
cbx.Text=coldat[enWHR]
TextBox1.Text=coldat[enWHR]
CASE enOR
cbx.Text=coldat[enOR]
TextBox1.Text=coldat[enOR]
CASE ELSE
' all other are asumed as 'enOR'
IF row<>enOFF THEN ' room for more then 100?
IF row>(coldat.count - 1) THEN Grid_AddRows2Column(2) 'vArrSQL2.Resize(row+1)
cbx.Text=coldat[row]
TextBox1.Text=coldat[row]
ENDIF
END SELECT
cbxDoChange=TRUE
END
More information about the User
mailing list