Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
Moderator: Rathinagiri
Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
Dear friends,
My friend Ben Dekker pointed me out some strange GRID behavior. He made a sample to demonstrate the problem ( see attachment ).
When you open the sample the grid is fine, see:
Pay attention to the column width of the most right column. The value perfectly fits in the configured column width. Now edit the most right column.
Do not change anything (keep the same value) and confirm the value with an enter. Now suddenly the GRID 'thinks' the column is not wide enough, but nothing changed !
Now double click the line next to the column to let the grid decide what the optimum column width should be:
The inplace edit function of the grid has changed the numeric field and even the value is still the same the column is much wider !
Now leave the the demo program and launch it again. Still the same data but now the column has the correct width again.
When I change the sample to use BROWSE in stead of a GRID it works just fine.
So there seems to be something wrong with the inplace GRID edit function when using a numeric field when using a DBF as row source.
I lack the knowledge to correct the HMG source to fix this.
Who can help ?
Theo
My friend Ben Dekker pointed me out some strange GRID behavior. He made a sample to demonstrate the problem ( see attachment ).
When you open the sample the grid is fine, see:
Pay attention to the column width of the most right column. The value perfectly fits in the configured column width. Now edit the most right column.
Do not change anything (keep the same value) and confirm the value with an enter. Now suddenly the GRID 'thinks' the column is not wide enough, but nothing changed !
Now double click the line next to the column to let the grid decide what the optimum column width should be:
The inplace edit function of the grid has changed the numeric field and even the value is still the same the column is much wider !
Now leave the the demo program and launch it again. Still the same data but now the column has the correct width again.
When I change the sample to use BROWSE in stead of a GRID it works just fine.
So there seems to be something wrong with the inplace GRID edit function when using a numeric field when using a DBF as row source.
I lack the knowledge to correct the HMG source to fix this.
Who can help ?
Theo
- Attachments
-
- GridBug.zip
- (1.52 MiB) Downloaded 138 times
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
It has to do with the width of the characters or numbers.
When designing my grids I multiply the number of max characters by 12 for width and multiply number of max numbers by 10 for numeric.
You can test this by filling a character field with W widest character, and numeric with 9+zeros.
In your example char = 12X12 = 144 and num = 12x10 120. this seems to work
It is somthing to do not the actual width of entry but maybe font setting, I can not figure out so I do as above, that way every word or
number fits.
When designing my grids I multiply the number of max characters by 12 for width and multiply number of max numbers by 10 for numeric.
You can test this by filling a character field with W widest character, and numeric with 9+zeros.
In your example char = 12X12 = 144 and num = 12x10 120. this seems to work
It is somthing to do not the actual width of entry but maybe font setting, I can not figure out so I do as above, that way every word or
number fits.
All The Best,
Franco
Canada
Franco
Canada
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
Franco,
Thanks for taking the time to answer my question. You are right about setting the column width more wide.
But this should not be necessary. Also the Windows auto optimum setting for the column is smaller. When you double click the line right of the column, Windows auto optimizes the width, like this:
Now in this new demo the column 2 (C_WITH) and column 3 (N_WITH) use the same data:
The only difference is the column 2 uses string data ('123456789012') and column 3 uses numeric data (123456789012).
When I edit column 2 and safe the cell without changing anything the cell looks like before ( like it should ).
Now here is the result with column 3.
The occupied width should be the same as in column 2. But it is not ! When I let Windows determine the optimum column width again (I double click the line right of column 3).
The result is:
After editing column 3 spaces in front seems to be added or otherwise the grid 'thinks' more width is required, but there is not !
Compare the required space for column 2 en 3. Column 3 is much wider for the same data !
Because this issue only occurs with numeric columns there must be some bug in the grid function.
I know, I can convert the numeric value to a string to workaround the issue, but the problem is still there.
Here the new sample to demonstrate the problem ( see attachment ).
Theo
Thanks for taking the time to answer my question. You are right about setting the column width more wide.
But this should not be necessary. Also the Windows auto optimum setting for the column is smaller. When you double click the line right of the column, Windows auto optimizes the width, like this:
Now in this new demo the column 2 (C_WITH) and column 3 (N_WITH) use the same data:
The only difference is the column 2 uses string data ('123456789012') and column 3 uses numeric data (123456789012).
When I edit column 2 and safe the cell without changing anything the cell looks like before ( like it should ).
Now here is the result with column 3.
The occupied width should be the same as in column 2. But it is not ! When I let Windows determine the optimum column width again (I double click the line right of column 3).
The result is:
After editing column 3 spaces in front seems to be added or otherwise the grid 'thinks' more width is required, but there is not !
Compare the required space for column 2 en 3. Column 3 is much wider for the same data !
Because this issue only occurs with numeric columns there must be some bug in the grid function.
I know, I can convert the numeric value to a string to workaround the issue, but the problem is still there.
Here the new sample to demonstrate the problem ( see attachment ).
Theo
- Attachments
-
- demo2.zip
- (1.52 MiB) Downloaded 120 times
- AUGE_OHR
- Posts: 2117
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
hi Theo,
Yes while "inline-edit" does display right
No while "inline-edit" is not Part of WC_LISTVIEW
---
when GRID have Focus press
YesNo ...Because this issue only occurs with numeric columns there must be some bug in the grid function.
Yes while "inline-edit" does display right
No while "inline-edit" is not Part of WC_LISTVIEW
---
when GRID have Focus press
Code: Select all
CTRL + "+" (NumPad + )have fun
Jimmy
Jimmy
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
Hi Jimmy,
Thanks for your response.
Do you mean the issue also occurs with other controls ?
The inplace GRID editing (in combination with a DBF rowsource) does show the proper layout but after saving ( with ENTER ) something goes wrong: the grid 'thinks' the column is too small.
When leaving the the inplace GRID edit with ESC the column stays intact.
Theo
Thanks for your response.
Do you mean the issue also occurs with other controls ?
The inplace GRID editing (in combination with a DBF rowsource) does show the proper layout but after saving ( with ENTER ) something goes wrong: the grid 'thinks' the column is too small.
When leaving the the inplace GRID edit with ESC the column stays intact.
Theo
- Claudio Ricardo
- Posts: 367
- Joined: Tue Oct 27, 2020 3:38 am
- DBs Used: DBF, MySQL, MariaDB
- Location: Bs. As. - Argentina
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
Hi Jimmy... when GRID have Focus press CTRL + "+" (NumPad + )
Thank you very much ! I did not know that shortcut for automatic adjustment !
Thank you very much ! I did not know that shortcut for automatic adjustment !
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
WhatsApp / Telegram: +54 911-63016162
- SALINETAS24
- Posts: 667
- Joined: Tue Feb 27, 2018 3:06 am
- DBs Used: DBF
- Contact:
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
Hola.
Creo que el problema viene por la longitud del número.
Si hacemos esto
Obtendremos el mismo resultado, la misma longitud, pero si le añadimos un dígito más al número al aplicar la función VAL, es cuando se "escogorcia".
Aquí, por arte de mágia se le añaden espacios en Blanco delante del numero en cuestión,
por lo tanto (y esta es mi humilde opinión), no es un problema del GRID, más bien fruto de la función VAL y del tamaño de la cifra.
Saludos y cervecita fresquita para todos
Creo que el problema viene por la longitud del número.
Si hacemos esto
Code: Select all
nValor="1234567890"
MSGBOX(nValor,LEN(nValor))
nValor:=VAL(nValor)
MSGBOX(nValor,len(str(nValor)))
Code: Select all
nValor="12345678901"
MSGBOX(nValor,LEN(nValor))
nValor:=VAL(nValor)
MSGBOX(nValor,len(str(nValor)))
Saludos y cervecita fresquita para todos
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. 
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
How can you set grid width if you do not set columns to what their max width could be. Capital W is widest letter. Zero is widest number.
All The Best,
Franco
Canada
Franco
Canada
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
Try with ...
@ Ren , Col GRID Gridx OF FormMain . . . . . . . FONT "Consolas" // Font Ancho fijo - Font fixed width
Although in the images the Font of the numbers looks the same width...
@ Ren , Col GRID Gridx OF FormMain . . . . . . . FONT "Consolas" // Font Ancho fijo - Font fixed width
Although in the images the Font of the numbers looks the same width...
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)
Thanks Andy seems to work good. I will try in my program grids.
All The Best,
Franco
Canada
Franco
Canada