How to change Column description in ListIconGadget ?

Just starting out? Need help? Post your questions and find answers here.
pickelrobert
User
User
Posts: 13
Joined: Sun Jul 18, 2004 2:24 pm
Location: Munich, Germany

How to change Column description in ListIconGadget ?

Post 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
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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
Last edited by netmaestro on Sat Feb 25, 2006 6:40 am, edited 4 times in total.
BERESHEIT
pickelrobert
User
User
Posts: 13
Joined: Sun Jul 18, 2004 2:24 pm
Location: Munich, Germany

Post by pickelrobert »

... and how look's this with column 0 - it will be defined on gadget creation ...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Works fine with column 0
Last edited by netmaestro on Tue Feb 21, 2006 10:27 pm, edited 2 times in total.
BERESHEIT
pickelrobert
User
User
Posts: 13
Joined: Sun Jul 18, 2004 2:24 pm
Location: Munich, Germany

Post 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.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I didn't mean SetGadgetText() I meant RemoveGadgetColumn() followed by AddGadgetColumn()
Last edited by netmaestro on Tue Feb 21, 2006 10:30 pm, edited 2 times in total.
BERESHEIT
pickelrobert
User
User
Posts: 13
Joined: Sun Jul 18, 2004 2:24 pm
Location: Munich, Germany

Post 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...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

How many gadget columns do you have?
Last edited by netmaestro on Tue Feb 21, 2006 10:32 pm, edited 3 times in total.
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
Last edited by netmaestro on Sat Feb 25, 2006 6:42 am, edited 3 times in total.
BERESHEIT
pickelrobert
User
User
Posts: 13
Joined: Sun Jul 18, 2004 2:24 pm
Location: Munich, Germany

Post by pickelrobert »

Many thanks. I will try your code.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
pickelrobert
User
User
Posts: 13
Joined: Sun Jul 18, 2004 2:24 pm
Location: Munich, Germany

Post 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 ?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

:oops: I was only using a single-column gadget! My remove-addback idea won't work for more columns, sorry. My mistake.
Last edited by netmaestro on Sat Feb 25, 2006 6:43 am, edited 3 times in total.
BERESHEIT
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply