Page 1 of 1

How to change Column description in ListIconGadget ?

Posted: Mon Jan 16, 2006 7:57 pm
by pickelrobert
Hello,

how can i change the column description in ListIconGadgets (not during creation) ? What's wrong ? Always testet (and not working) variants:

Code: Select all

SetGadgetItemText(0,0,"column0",0)
;or
SetGadgetText(0,"column0")
Thanks

Posted: Mon Jan 16, 2006 8:12 pm
by netmaestro
You can delete the column and add it back again, no data will be lost. [edit] This isn't a good idea, better ways are found below

Posted: Mon Jan 16, 2006 8:16 pm
by pickelrobert
... and how look's this with column 0 - it will be defined on gadget creation ...

Posted: Mon Jan 16, 2006 8:21 pm
by netmaestro
Works fine with column 0

Posted: Mon Jan 16, 2006 8:27 pm
by pickelrobert
I try to change the "TEXT" created with:

Code: Select all

ListIconGadget(0, 20, 90,470,290,"TEXT",225,#PB_ListIcon_GridLines)
with

Code: Select all

SetGadgetText(0,"NEW TEXT")
in my meaning this ist column 0. But this don't work.

Posted: Mon Jan 16, 2006 8:42 pm
by netmaestro
I didn't mean SetGadgetText() I meant RemoveGadgetColumn() followed by AddGadgetColumn()

Posted: Mon Jan 16, 2006 8:49 pm
by pickelrobert
Yes and yes i know. My Gadget is always filled and i want change the column description for column 0 - defined on gadget creation with the "text" property...

Posted: Mon Jan 16, 2006 8:55 pm
by netmaestro
How many gadget columns do you have?

Posted: Mon Jan 16, 2006 9:11 pm
by netmaestro
[edit] New for Version 4 Beta 4, best way: SetGadgetItemText(#Gadget, Item, Text$, Column) If Item = -1, the header text of the given column is changed.

Posted: Tue Jan 17, 2006 3:06 pm
by pickelrobert
Many thanks. I will try your code.

Posted: Tue Jan 17, 2006 3:58 pm
by gnozal
You can also use this (windows only) :

Code: Select all

lvc.LV_COLUMN 
lvc\mask = #LVCF_TEXT 
lvc\pszText = @"NEW TEXT" 
SendMessage_(GadgetID(#MyListIcon), #LVM_SETCOLUMN, ColumnIndex, @lvc)

Posted: Tue Jan 17, 2006 4:08 pm
by pickelrobert
I tryed this out with a little bit modified code

Code: Select all

Enumeration
  #MyWindow
  #MyGadget
  #ReturnCatch
EndEnumeration

hscol0.s = "Columnheader 0"
hscol1.s = "Columnheader 1"
 If OpenWindow(#MyWindow,0,0,430,300,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Header Text demo")
   If CreateGadgetList(WindowID())
     ListIconGadget(#MyGadget,10,10,410,230,hscol0,200,#PB_ListIcon_GridLines)
     AddGadgetColumn(#MyGadget,1,hscol1,200)
     AddGadgetItem(#MyGadget,-1,"Press Enter to Change Header"+Chr(10)+"and data of this part will be lost") ;Sets line height
     AddKeyboardShortcut(#MyWindow,#PB_Shortcut_Return,#ReturnCatch)
     Repeat
       EventID = WaitWindowEvent()
       Select EventID
         Case #PB_Event_Menu
            If EventMenuID() = #ReturnCatch
              If hscol0 = "Columnheader 0"
                 hscol0.s = "Spaltenkopf 0"
                 hscol1.s = "Spaltenkopf 1"
              Else
                 hscol0.s = "Columnheader 0"
                 hscol1.s = "Columnheader 1"
              EndIf
              RemoveGadgetColumn(#MyGadget,1)
              RemoveGadgetColumn(#MyGadget,0)
              AddGadgetColumn(#MyGadget,0,hscol0,200)
              AddGadgetColumn(#MyGadget,1,hscol1,200)
            EndIf
       EndSelect
     Until EventID = #PB_Event_CloseWindow And EventWindowID() = #MyWindow
   EndIf
 EndIf
But there happens, what i not want - all data right of column 0 will be lost ...

@gnozal
is this snippet code for linux available too ?

Posted: Tue Jan 17, 2006 4:17 pm
by netmaestro
:oops: I was only using a single-column gadget! My remove-addback idea won't work for more columns, sorry. My mistake.

Posted: Tue Jan 17, 2006 4:35 pm
by gnozal
pickelrobert wrote:@gnozal
is this snippet code for linux available too ?
Sorry, it's Windows API only.
I suppose there is a GTK equivalent for Linux but I don't know Linux.