NetTalk Central

Author Topic: Programatically set Listbox Cell Display format and Data  (Read 2115 times)

Riebens

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
I have a listbox and one of the columns must be 55 chars wide ...  The data that come back from the table is more than that ...

I want to be able to intercept the data .. count the characters ... If MORE than 52,  Sub the first 52 and & '...'  [ asadasdasdfg... ] and display that , else if the data is less than 52 , display as is ....

Any help on WHERE to do this using netwebbrowse template would be appreciated

Kind Regards

Ben

Rene Simons

  • Hero Member
  • *****
  • Posts: 649
    • View Profile
Re: Programatically set Listbox Cell Display format and Data
« Reply #1 on: May 18, 2010, 07:49:31 AM »
Hi Ben,
Populate the listbox with a local variable exactly as wide as you need.
Then in embed point 'SetQueueRecord' do:
local:variable = databaseVar,

Rene
Rene Simons
NT14.14

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Programatically set Listbox Cell Display format and Data
« Reply #2 on: May 18, 2010, 03:05:28 PM »
The only prob with local variables in my experience is you can't sort on them properly in a list box. You may be better just doing a sub on the field in the embed Rene suggested. eg INV:DESC = Sub(INV:DESC,1,52)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11194
    • View Profile
Re: Programatically set Listbox Cell Display format and Data
« Reply #3 on: May 18, 2010, 10:00:16 PM »
Rene's on the right track - and there's a way to do the sorting as well.

So firstly Rene's bit. While you can make a local variable, it's not necessary. The 'Display' field (which is usually blank for a browse column) can contain an expression. If empty the "Field:" value is used (obviously) but regardless of the field, anything can go in the Display setting.

In Ben's case a rather complex expression would work very well. Something like this;
Choose(Len(Clip(Inv:Desc))>52, Sub(Inv:Desc,1,49) & '...' , Inv:Desc)

By bypassing the local variable, the sorting problem Kevin raises goes away - however there will be times when a local variable IS appropriate. In those cases go to the SORT tab for the browse column, and enter the custom sort there. Now obviously you're limited to sorting on the fields in the database - so if your expression does something really different (like say decrypt a string) then you're fresh out of luck. However in Ben's case, if he did the Local Variable thing, he'd still be able to sort on Inv:Desc

Cheers
Bruce