AndyGB4
Posts: 122
|
Posted: 03/15/2017, 8:09 AM |
|
Hi, i know this forum is mostly dead, but I'll give it a try anyway because I'm stuck...
I have a ListBox, and for the sake of this example, it has ApplID as its Bound Column, and ApplNameEN as its Text Column.
How can I change the Text Column dynamically? I'd like to show ApplNameFR as the Text Column instead if a certain session equals a certain value.
I've tried changing it in the before show event, using "DataTextField" but no luck.
Any help or ideas would be greatly appreciated, thanks!
- Andrew
|
 |
 |
cvboucher
Posts: 191
|
Posted: 03/15/2017, 10:09 AM |
|
I don't know for sure if this will work but what if you changed the query type to SQL, add a parameter that comes from your session variable, then do a CASE statement for the text column that looks at the parameter to determine which column to return.
SELECT
ApplID,
CASE '{SessionParam}' WHEN 'EN' THEN ApplNameEN ELSE ApplNameFR END As ApplNameEN
FROM ApplTable
ORDER BY CASE '{SessionParam}' WHEN 'EN' THEN ApplNameEN ELSE ApplNameFR END
Craig
|
 |
 |
AndyGB4
Posts: 122
|
Posted: 03/15/2017, 11:20 AM |
|
Good idea, I'll give that a shot.
Thanks!
|
 |
 |
vsuarez
Posts: 8
|
Posted: 03/15/2017, 6:21 PM |
|
Hi Andrew,
You should also try in the AfterInitialize event using the following code:
theForm.GetControl<MTListBox>("the_listbox").DataTextField = "column_name";
Good luck,
Victor
|
 |
 |
AndyGB4
Posts: 122
|
Posted: 03/16/2017, 6:09 AM |
|
Thanks, cvboucher, your idea worked perfectly.
I adapted it to work with more languages, and i also added some code to make sure that if the field is empty, it would default to English.
vsuarez, that's the exact line of code I used, but I put in the wrong place. I'll keep this in mind.
Thanks guys!
|
 |
 |
|