DCBROWSECOL ... HIDE

This forum is for eXpress++ general support.
Post Reply
Message
Author
skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

DCBROWSECOL ... HIDE

#1 Post by skiman »

Hi,

I'm trying to hide/show a column in a browse. I don't succeed to get this working as it should.

I can hide, but when I want to show it again, it looks as another column is overwritten. I tried refreshall, forcestable() but it doens't work as expected.

Below is my sample code which demonstrates the problem.
- You can hide column 2.
- When you want to show it again, it comes instead of column1 which looks as it disappears.

Code: Select all

function testbrowse()
****************************************
Local getlist := {} , oBrowse
Local aTestData := { {"abc","xyz",123} }
Local lDisplay := .T.

@ 1,1 dcbrowse oBrowse data atestdata SIZE 40,10 FIT
DCBROWSECOL ELEMENT 1 HEADER "Col 1 " PARENT oBrowse WIDTH 10
DCBROWSECOL ELEMENT 2 HEADER "Col 2 " PARENT oBrowse WIDTH 10 HIDE {|| !lDisplay }
DCBROWSECOL ELEMENT 3 HEADER "Col 3 " PARENT oBrowse WIDTH 10

@12,10 dcpushbuttonxp ;
	CONFIG amain(2,17) ;
	CAPTION 'SHOW Col 2' notabstop ;
	SIZE 20,1  ;
		ACTION {||lDisplay := .T. ,DC_GetRefresh(getlist), oBrowse:refreshall(), setAppfocus(oBrowse) }
@12,32 dcpushbuttonxp ;
	CONFIG amain(2,17) ;
	CAPTION 'HIDE Col 2' notabstop ;
	SIZE 20,1  ;
		ACTION {||lDisplay:=.F. ,DC_GetRefresh(getlist),obrowse:gotop(),oBrowse:refreshall(), oBrowse:forceStable(), setAppfocus(oBrowse) }

DCREAD GUI ;
	TITLE 'Test Hide/Show Col' FIT 
	
return nil
Best regards,

Chris.
www.aboservice.be

User avatar
slobodan1949
Posts: 80
Joined: Mon Apr 25, 2011 8:57 am
Location: SERBIA
Contact:

Re: DCBROWSECOL ... HIDE

#2 Post by slobodan1949 »

* Solution variant A "HALF eXpress++"
****************************************
function testbrowse()
****************************************
Local getlist := {} , oBrowse
Local aTestData := { {"abc","xyz",123} }

@ 1,1 dcbrowse oBrowse data atestdata SIZE 40,10 FIT
DCBROWSECOL ELEMENT 1 HEADER "Col 1 " PARENT oBrowse WIDTH 10 OBJECT c1
DCBROWSECOL ELEMENT 2 HEADER "Col 2 " PARENT oBrowse WIDTH 10 OBJECT c2
DCBROWSECOL ELEMENT 3 HEADER "Col 3 " PARENT oBrowse WIDTH 10 OBJECT c3

@12,10 dcpushbuttonxp ;
CAPTION 'HIDE Col 2' notabstop ;
SIZE 20,1 ;
ACTION {|| ;
c2:Hide(),;
oBrowse:refreshall(), setAppfocus(oBrowse) }
@12,32 dcpushbuttonxp ;
CAPTION 'SHOW Col 2' notabstop ;
SIZE 20,1 ;
ACTION {|| ;
c2:Show(),;
oBrowse:refreshall(), setAppfocus(oBrowse) }

DCREAD GUI ;
TITLE 'Test Hide/Show Col' FIT
return nil




* Solution variant B "COMPLETELY eXpress++"
****************************************
function testbrowse()
****************************************
Local getlist := {} , oBrowse
Local aTestData := { {"abc","xyz",123} }

Local cHide := memoread("lHide") // "1" or ""
IF cHide = "1"
lHide := .T.
ELSE
lHide := .F.
ENDIF

@ 1,1 dcbrowse oBrowse data atestdata SIZE 40,10 FIT
DCBROWSECOL ELEMENT 1 HEADER "Col 1 " PARENT oBrowse WIDTH 10
DCBROWSECOL ELEMENT 2 HEADER "Col 2 " PARENT oBrowse WIDTH 10 HIDE {|| lHide }
DCBROWSECOL ELEMENT 3 HEADER "Col 3 " PARENT oBrowse WIDTH 10

PRIVATE restart := .F.

@12,10 dcpushbuttonxp ;
CAPTION 'HIDE Col 2' notabstop ;
SIZE 20,1 ;
ACTION {|| ;
memowrit("lHide","1"),;
restart:=.T.,;
DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

@12,32 dcpushbuttonxp ;
CAPTION 'SHOW Col 2' notabstop ;
SIZE 20,1 ;
ACTION {|| ;
memowrit("lHide",""),;
restart:=.T.,;
DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

DCREAD GUI ;
TITLE 'Test Hide/Show Col' FIT

if restart==.T.
testbrowse()
endif
return nil

* Solution variant C "FULL eXpress++"
* Consult the 'Roger Donnay Group'

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: DCBROWSECOL ... HIDE

#3 Post by skiman »

Hi,

Thanks for the response.

With Solution A the column is not really hidden. It gets a blank column, but it still remains in the browse.
Solution be can also be accomplished with a do while. I was hoping on a more efficient solution.

I will see, or I use solution B or I create multiple browses on a static and use a show/hide system on the statics. Just have to test what's best concerning 'flickering' of the screen.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSECOL ... HIDE

#4 Post by rdonnay »

I recommend looking at the source code of SqlQuery.prg.

The browse system allows you to collapse and restore columns.
First you tag columns with a right-click in the header, then select collapse.
The eXpress train is coming - and it has more cars.

k-insis
Posts: 100
Joined: Fri Jan 28, 2011 4:07 am

Re: DCBROWSECOL ... HIDE

#5 Post by k-insis »

Can you try setting columns horizontal size to zero and leaving vertical size as is ?
skiman wrote: Mon Feb 05, 2024 1:51 am Hi,

Thanks for the response.

With Solution A the column is not really hidden. It gets a blank column, but it still remains in the browse.
Solution be can also be accomplished with a do while. I was hoping on a more efficient solution.

I will see, or I use solution B or I create multiple browses on a static and use a show/hide system on the statics. Just have to test what's best concerning 'flickering' of the screen.

User avatar
SlavkoDam
Posts: 86
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: DCBROWSECOL ... HIDE

#6 Post by SlavkoDam »

Hi,

This is a code from my library PowerWin for hide/show a browse column. You can use it for free. It is simple, elegant, efficient and makes no flickers on the screen. To understand the code, you should read the XbpBrowse() source code in SOURCE\RUNTIME\DUI. This is the right way how to do that task.

Code: Select all

FUNCTION BRWCOLHIDE(oBrw,col_pos)
**
LOCAL oPanel,aPos,wdt,I, oCol := oBrw:getColumn(col_pos)
**
IF !oCol:isVisible() .OR. ASCAN(oBrw:setLeftFrozen(),col_pos) > 0 .OR. ;
   ASCAN(oBrw:setRightFrozen(),col_pos) > 0
  RETURN .F.
ENDIF
oPanel = oCol:setParent()
oPanel:lockUpdate(.T.)
wdt = oCol:currentSize()[1]
oCol:hide()
FOR I = (col_pos + 1) TO oBrw:colCount
  oCol = oBrw:getColumn(I)
  aPos = oCol:currentPos()
  oCol:setPos({aPos[1] - wdt,aPos[2]})
NEXT
oBrw:panEnd():panHome()
oPanel:lockUpdate(.F.)
oPanel:invalidateRect()
RETURN .T.

FUNCTION BRWCOLSHOW(oBrw,col_pos)
**
LOCAL oPanel,aPos,wdt,I, oCol := oBrw:getColumn(col_pos)
**
IF oCol:isVisible() .OR. ASCAN(oBrw:setLeftFrozen(),col_pos) > 0 .OR. ;
   ASCAN(oBrw:setRightFrozen(),col_pos) > 0
  RETURN .F.
ENDIF
oPanel = oCol:setParent()
oPanel:lockUpdate(.T.)
wdt = oCol:currentSize()[1]
oCol:show()
FOR I = oBrw:colCount TO (col_pos + 1) STEP -1
  oCol = oBrw:getColumn(I)
  aPos = oCol:currentPos()
  oCol:setPos({aPos[1] + wdt,aPos[2]})
NEXT
oBrw:panEnd():panHome()
oPanel:lockUpdate(.F.)
oPanel:invalidateRect()
RETURN .T.

Best regards,

Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: DCBROWSECOL ... HIDE

#7 Post by skiman »

Hi SlavcoDam,

Thanks for the sample code. I will try it.
Best regards,

Chris.
www.aboservice.be

User avatar
SlavkoDam
Posts: 86
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

Re: DCBROWSECOL ... HIDE

#8 Post by SlavkoDam »

Hi Cris,

I am interested did you try my code and does it work well?
Best regards,

Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: DCBROWSECOL ... HIDE

#9 Post by skiman »

Hi,

Your code is working fine.
Best regards,

Chris.
www.aboservice.be

Post Reply