Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Display blank in grid instead of 0

1,934 views
Skip to first unread message

Sithu

unread,
Sep 17, 2009, 4:47:34 AM9/17/09
to
Hi all,

I have a column in a grid related on a numeric field with value zero.
When I open the form, the grid does display the zero and that is NOT
what I want.
What I want is to display blank instead of zero.

What shall I do?
Thank you in advance.

Mike Gagnon

unread,
Sep 17, 2009, 6:53:05 AM9/17/09
to
Add another textbox (not bound to the numeric field) or add a label in
column and use DynamicCurrentcontrol to alternate between. If there is a
value other than 0, show your bound textbox, otherwise show the label.
"Sithu" <cith...@gmail.com> wrote in message
news:49a26808-2b6d-4551...@v37g2000prg.googlegroups.com...

Dan Freeman

unread,
Sep 17, 2009, 10:44:47 AM9/17/09
to
If you put Z in the format property of the textbox, it'll display blank if
zero except when the textbox has focus.

Will that do?

Dan

Sithu

unread,
Sep 18, 2009, 1:37:04 AM9/18/09
to

Thank you all.

I used the following command for the fields which value is zero for
the bound table
BLANK FIELDS fieldName

Sithu

unread,
Sep 18, 2009, 1:43:50 AM9/18/09
to
On Sep 17, 4:53 pm, "Mike Gagnon" <mgagno...@hotmail.com> wrote:
> Add another textbox (not bound to the numeric field) or add a label in
> column and use DynamicCurrentcontrol to alternate between. If there is a
> value other than 0, show your bound textbox, otherwise show the label."Sithu" <cithuk...@gmail.com> wrote in message

>
> news:49a26808-2b6d-4551...@v37g2000prg.googlegroups.com...
>
> > Hi all,
>
> > I have a column in a grid related on a numeric field with value zero.
> > When I open the form, the grid does display the zero and that is NOT
> > what I want.
> > What I want is to display blank instead of zero.
>
> > What shall I do?
> > Thank you in advance.

Thank you for your advice.
I create the columns at runtime. How will you implement your advice ?
Can you give me a code sample ?

Stefan Wuebbe

unread,
Sep 18, 2009, 1:43:20 AM9/18/09
to

Since yours is a display issue, I would suggest to go the
form.grid.column.Format="Z" way instead of manipulating actual content.


hth
-Stefan

Bernhard Sander

unread,
Sep 18, 2009, 5:30:00 AM9/18/09
to
Hi Sithu

>> Add another textbox (not bound to the numeric field) or add a label in
>> column and use DynamicCurrentcontrol to alternate between. If there is a
>> value other than 0, show your bound textbox, otherwise show the label."Sithu" <cithuk...@gmail.com> wrote in message
>>

>>> Hi all,
>>> I have a column in a grid related on a numeric field with value zero.
>>> When I open the form, the grid does display the zero and that is NOT
>>> what I want.
>>> What I want is to display blank instead of zero.
>>> What shall I do?
>>> Thank you in advance.
>

> I create the columns at runtime. How will you implement your advice ?


Create an new class and inherit from base class "Column". This must be done in a
prg, not with a designer. There you set, as others wrote, .Format to "Z". In
your grid, you set .MemberClass and .MemberClassLibrary to the new class and its
file, this you can do in the designer. From now on, the grid creates all columns
based on this class.

DEFINE CLASS MyColumn AS column
Format = "Z"
ENDDEFINE


Another solution:
Create your column class as above.
At runtime after your grid is filled, set .MemberClass and .MemberClassLibrary
to the new class, delete the column with the wrong display behaviour, add an new
column based on your column and set its control source to the respective field.
At the end, reset the .MemberClass properties

theGrid.MemberClass = "MyColumn"
theGrid.MemberClassLibrary = "maybe\path\MyColumns.prg"
FOR i = 1 TO theGrid.ColumnCount
IF upper(theGrid.Columns(i).Controlsource) = "THEFIELD"
theGrid.DeleteColumn(i)
theGrid.AddColumn(i)
theGrid.Columns(theGrid.ColumnCount).ControlSource = "THEFIELD"
EXIT
ENDIF
ENDFOR
theGrid.MemberClass = ""
theGrid.MemberClassLibrary = ""

Attention:
the index in AddColumn tells, where to place the new column visually, but the
new column is added to the end of the internal column list. Therefor you must
reference the new column by theGrid.Columns(theGrid.ColumnCount)

Advantage of this solution: all the other columns have default behaviour, only
the special column has special behaviour.
Disadvantage: you have to maintain column creation everytime you change the
.RecordSource of the grid.

Regards
Bernhard Sander

Sithu

unread,
Sep 18, 2009, 6:38:59 AM9/18/09
to

Thank you for your help,

With Regards,
Sithu

0 new messages