If the column width is smaller than the text it automatically wraps the text.
Is there a way to prevent the text from wrapping automatically? It only wraps when I define CRLF?




Yes. There should be a property in the xBrowse/TXBrwColumn class like: lColWrapTextAutomatic := .F.
Sorry,Giovany Vecchi wrote: Wed May 21, 2025 6:30 pmYes. There should be a property in the xBrowse/TXBrwColumn class like: lColWrapTextAutomatic := .F.
In this case the desired column would only wrap the text if CRLF was included CRLF.
Hi Navarro.cnavarro wrote: Thu May 22, 2025 7:06 am Sorry,
Do you have defined
<ocol>:nDataLines := 1 or <oBrw>:nDatalines := 1 ?
For now, use the data <oCol>:bPaintTextGiovany Vecchi wrote: Thu May 22, 2025 1:06 pmHi Navarro.cnavarro wrote: Thu May 22, 2025 7:06 am Sorry,
Do you have defined
<ocol>:nDataLines := 1 or <oBrw>:nDatalines := 1 ?
I have a CRLF to display on 2 lines. If one of the lines is longer than the cell length, it automatically wraps and displays on 3 lines.
I want it to be displayed on 2 lines without cutting off the second line because of the automatic wrap.
Code: Select all | Expand
Eval( ::bPaintText, Self, hDC, cStrData, oRect:aRect, aColors, lHighLite, lSelected )Code: Select all | Expand
Data lColWrapTextAutomatic AS LOGICAL INIT .T. // GiovanyCode: Select all | Expand
if Empty( ::aDataFont ) .and. Empty( ::aClrText )
If ::lColWrapTextAutomatic //Giovany
::oBrw:SayText( cData, aRect, cAlign, oFont, aColors[ 1 ], nil, nil, nOr( DT_MODIFYSTRING, DT_EDITCONTROL, DT_NOPREFIX ) )
Else
FW_SayText( hDC, cData, aRect, cAlign, oFont, aColors[ 1 ], nil, nil, nOr( DT_MODIFYSTRING, DT_EDITCONTROL, DT_NOPREFIX ),.F. ) //Giovany .F. Not Word break
EndIf
else
Code: Select all | Expand
//Parameter lWordBreak
function FW_SayText( oWnd, cText, aRect, cAlign, oFont, nClrText, nClrBack, lBorder, nAddStyle, lWordBreak ) // oWnd or hDC
//Default
Default lWordBreak := .T. //In order not to change existing codes (Giovany)
//Block
nStyle := nHAlign
if lSingleLine
nStyle += nVAlign + DT_SINGLELINE
nStyle := nOr( nStyle, nAddStyle )
else
if lWordBreak
nStyle += DT_WORDBREAK //Do not automatically break the line (Giovany)
EndIf
if Empty( aText )
if nVAlign != DT_TOP // DT_TOP is 0
if nVAlign == DT_BOTTOM
aRect[ 1 ] := Max( aRect[ 1 ], aRect[ 3 ] - nHeight )
else
aRect[ 1 ] := Max( aRect[ 1 ], Int( ( aRect[ 3 ] + aRect[ 1 ] - nHeight ) / 2 ) )
endif
endif
else
nStyle := nOr( nStyle, nVAlign )
endif
nStyle := nOr( nStyle, nAddStyle )
Code: Select all | Expand
METHOD DefStyle( nAlign, lSingleLine ) CLASS TXBrwColumn
local nStyle, nVAlign
.../...
if lSingleLine
nStyle := nOr( nStyle, DT_SINGLELINE, nVAlign ) //DT_VCENTER)
else
if ::lColWrapText // New Data
nStyle := nOr( nStyle, DT_WORDBREAK)
endif
endif
return nStyle
It didn't work.cnavarro wrote: Thu May 22, 2025 9:24 pm Try only with this pleaseCode: Select all | Expand
METHOD DefStyle( nAlign, lSingleLine ) CLASS TXBrwColumn local nStyle, nVAlign .../... if lSingleLine nStyle := nOr( nStyle, DT_SINGLELINE, nVAlign ) //DT_VCENTER) else if ::lColWrapText // New Data nStyle := nOr( nStyle, DT_WORDBREAK) endif endif return nStyle
Code: Select all | Expand
#include "fivewin.ch"
#include "xbrowse.ch"
function main()
local oWnd
local oGrid
local oBtn, oGet1, oGet2
DEFINE WINDOW oWnd
// oWnd:nHeight := ScreenHeight()
// oWnd:nWidth := ScreenWidth()
ACTIVATE WINDOW oWnd MAXIMIZED ON INIT Controles( oWnd )
Return nil
Function Controles( oWnd )
local oGrid
local aData := { { "En un lugar de la Mancha de cuyo nombre no quiero acordarme" + CRLF + "Linea2", "Datos2" }, ;
{ "vivia un hidalgo caballero de nombre Don Quijote que gustaba de la lectura de libros de caballeria" + CRLF + "Linea21", "Datos22" } }
@ 10, 151 XBROWSE oGrid ;
SIZE 600, 400 PIXEL ; /// -1, -1
OF oWnd ;
DATASOURCE aData;
AUTOSORT ;
AUTOCOLS ;
CELL LINES NOBORDER
WITH OBJECT oGrid
:oCol(1):nWidth := 300
:oCol(2):nWidth := 300
//:nDataLines := 2
:CreateFromCode()
END
Return nil
Hi Navarro.cnavarro wrote: Fri May 23, 2025 7:11 pm Dear Giovanny, please try with this sample and send me image of xbrowse
Code: Select all | Expand
#include "fivewin.ch" #include "xbrowse.ch" function main() local oWnd local oGrid local oBtn, oGet1, oGet2 DEFINE WINDOW oWnd // oWnd:nHeight := ScreenHeight() // oWnd:nWidth := ScreenWidth() ACTIVATE WINDOW oWnd MAXIMIZED ON INIT Controles( oWnd ) Return nil Function Controles( oWnd ) local oGrid local aData := { { "En un lugar de la Mancha de cuyo nombre no quiero acordarme" + CRLF + "Linea2", "Datos2" }, ; { "vivia un hidalgo caballero de nombre Don Quijote que gustaba de la lectura de libros de caballeria" + CRLF + "Linea21", "Datos22" } } @ 10, 151 XBROWSE oGrid ; SIZE 600, 400 PIXEL ; /// -1, -1 OF oWnd ; DATASOURCE aData; AUTOSORT ; AUTOCOLS ; CELL LINES NOBORDER WITH OBJECT oGrid :oCol(1):nWidth := 300 :oCol(2):nWidth := 300 //:nDataLines := 2 :CreateFromCode() END Return nil

Code: Select all | Expand
:bStrData := {||AllTrim(::oDs_RegistroAtos:N_REGISTRO_ATOS_cEventoServico)+CRLF+;
AllTrim( G_SELO_PAR_N_ATO_PRATICADO(3,,::oDs_RegistroAtos:N_REGISTRO_ATOS_cAtoCiaSigla) ) }