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

How to remove trailing and leading spaces, and prevent empty data, on an item within a treview on user label edit?

914 views
Skip to first unread message

Alex Castillo

unread,
Jul 15, 2009, 8:49:39 AM7/15/09
to
Hello...

Using Powerbuilder 7.0

How to remove trailing and leading spaces, and prevent empty data, on an
item within a treview on user label edit?

Thanks..!


Chris Pollach

unread,
Jul 15, 2009, 9:10:47 AM7/15/09
to
Hi Alex;

Just use the PB built-in commands: Trim ( ), LeftTrim ( ) or RightTrim
( ) as required.

Note: You can often set this type of trimming option in your database
driver - via the DBParm settings (if your DBMS/Driver supports it).

HTH

--
Regards ... Chris
ISUG - NA RUG Director
http://chrispollach.pbdjmagazine.com


"Alex Castillo" <a...@m.com> wrote in message
news:4a5dd063$1...@forums-3-dub.sybase.com...

Alex Castillo

unread,
Jul 15, 2009, 9:18:23 AM7/15/09
to
Sure, but I need the user to see I'm trimming his/her entry, so I need to
actually trim what the treeview is displaying on the edited item. I've tried
trimming 'newtext' on the treeview's EndLabelEdit event, but it doesn't
seems to work...

Any idea?

P.S.: The other post I placed, is in regards the same situation but within a
column within a datawindow... I've tried trimming 'data' on the datawindow's
ItemChanged, but it doesn't seems to work for me either...


"Chris Pollach" <cpol...@travel-net.com> wrote in message
news:4a5dd557$1...@forums-3-dub.sybase.com...

Chris Pollach

unread,
Jul 15, 2009, 9:37:22 AM7/15/09
to

For the DW - use the DB driver trim option or use the DBMS trim ( )
commands is your Select statement. For example ...

Select Trim (First_name),
Trim (Last_Name),
.... FROM ....
;

As far as the TV Item is concerned it should work. However PB 7 is so old
I can not say so sure that there is not a TV bug you are experiencing. I
would suggest that you post a simple example application for us to look at
but, I doubt anyone would still be using PB 7. The lowest version I have
installed currently is now PB 10.5.2.

"Alex Castillo" <a...@m.com> wrote in message

news:4a5dd71f$2...@forums-3-dub.sybase.com...

Ivaylo Ivanov

unread,
Jul 15, 2009, 10:19:59 AM7/15/09
to
As for the DW's ItemChanged event you should return 2 (reject the data but
allow the focus to change) in order to put the trimmed value instead of the
modified one:

// String with spaces only ' ' or empty string '' is NULL
// Otherwise trim the value
string ls_new_value
string ThisIsNullString
setnull(ThisIsNullString)

if dwo.Name = "mycolumn" then
ls_new_value = trim(data)
if ls_new_value = "" then ls_new_value = ThisIsNullString
this.SetItem(row, string(dwo.Name), ls_new_value)
return (2)
end if

Regards,
Ivaylo

"Alex Castillo" <a...@m.com> wrote in message

news:4a5dd71f$2...@forums-3-dub.sybase.com...

Ivaylo Ivanov

unread,
Jul 15, 2009, 10:27:07 AM7/15/09
to
As for the treeview, newtext argument of the EndLabelEvent is probably for
information only. You can try something complicated in this event, for
example:

TreeViewItem tvi
this.GetItem(handle, tvi)
tvi.Label = trim(newtext)
this.Post SetItem(handle, tvi)
return 1

The idea is to get a reference to the edited treeviewitem, modify its Label
property with the trimmed newtext and store the modification to the treeview
control rejecting (return 1) the user modification.

Ivaylo

"Alex Castillo" <a...@m.com> wrote in message

news:4a5dd71f$2...@forums-3-dub.sybase.com...

Alex Castillo

unread,
Jul 15, 2009, 11:49:10 AM7/15/09
to
Thanks to all...

"Chris Pollach" <cpol...@travel-net.com> wrote in message
news:4a5dd557$1...@forums-3-dub.sybase.com...

0 new messages