Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by trmpluym »

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:
2022-03-06 13_33_48-Test inputmask_OK.png
2022-03-06 13_33_48-Test inputmask_OK.png (4.5 KiB) Viewed 4411 times

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.
2022-03-06 13_36_18-Test inputmask_EDIT.png
2022-03-06 13_36_18-Test inputmask_EDIT.png (3.84 KiB) Viewed 4411 times

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 !
2022-03-06 13_37_03-Test inputmask_FAULT.png
2022-03-06 13_37_03-Test inputmask_FAULT.png (3.86 KiB) Viewed 4411 times

Now double click the line next to the column to let the grid decide what the optimum column width should be:
2022-03-06 13_48_46-Test inputmask_Click.png
2022-03-06 13_48_46-Test inputmask_Click.png (4.65 KiB) Viewed 4411 times

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 !
2022-03-06 13_52_33-Test inputmask_too_wide.png
2022-03-06 13_52_33-Test inputmask_too_wide.png (5.17 KiB) Viewed 4411 times

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 137 times
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by franco »

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.
All The Best,
Franco
Canada
trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by trmpluym »

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:

1.png
1.png (4.86 KiB) Viewed 4286 times

Now in this new demo the column 2 (C_WITH) and column 3 (N_WITH) use the same data:

2.png
2.png (4.43 KiB) Viewed 4286 times

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 ).

3.png
3.png (3.99 KiB) Viewed 4286 times
4.png
4.png (3.63 KiB) Viewed 4286 times

Now here is the result with column 3.

5.png
5.png (3.49 KiB) Viewed 4286 times
6.png
6.png (3.9 KiB) Viewed 4286 times

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).

8.png
8.png (5.2 KiB) Viewed 4286 times

The result is:

9.png
9.png (3.54 KiB) Viewed 4286 times

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 119 times
User avatar
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)

Post by AUGE_OHR »

hi Theo,
Because this issue only occurs with numeric columns there must be some bug in the grid function.
YesNo ...

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
trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by trmpluym »

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
User avatar
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)

Post by Claudio Ricardo »

Hi Jimmy... when GRID have Focus press CTRL + "+" (NumPad + )
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
User avatar
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)

Post by SALINETAS24 »

Hola.

Creo que el problema viene por la longitud del número. :geek:

Si hacemos esto

Code: Select all

			nValor="1234567890"
			MSGBOX(nValor,LEN(nValor))
			nValor:=VAL(nValor)
			MSGBOX(nValor,len(str(nValor)))
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".

Code: Select all

			nValor="12345678901"
			MSGBOX(nValor,LEN(nValor))
			nValor:=VAL(nValor)
			MSGBOX(nValor,len(str(nValor)))
Aquí, por arte de mágia se le añaden espacios en Blanco delante del numero en cuestión, :shock: 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
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by franco »

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
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by andyglezl »

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...
Andrés González López
Desde Guadalajara, Jalisco. México.
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Bug in ColumnWidth GRID after inplace edit of numeric field (DBF ROWSOURCE)

Post by franco »

Thanks Andy seems to work good. I will try in my program grids.
All The Best,
Franco
Canada
Post Reply