View previous topic :: View next topic |
Author |
Message |
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Thu Jul 18, 2013 6:34 am Post subject: How to set colum width? |
|
|
hey,
Im facing another problem, this time with listview.
Im incapable to set the colum width.
I've this great,
Code: | self.FormLv = createListView(self.MainForm)
setProperty(self.FormLv, 'ViewStyle', 'vsReport')
setProperty(self.FormLv, 'RowSelect', 'True')
setProperty(self.FormLv, 'ReadOnly', 'True')
self.FormLv.height = self._lvheight
self.FormLv.width = self._lvwidth
self.FormLvC = self.FormLv.getColumns()
self.FormLvColum1 = self.FormLvC.add()
self.FormLvColum2 = self.FormLvC.add()
self.FormLvColum1.Caption = self._lvc1caption
self.FormLvColum2.Caption = self._lvc2caption |
But doing
Code: | self.FormLvColum1.Width = self._lvculomwidth
self.FormLvColum2.Width = self._lvculomwidth |
or
Code: | self.FormLvColum1.MinWidth = self._lvculomwidth
self.FormLvColum2.MinWidth = self._lvculomwidth
self.FormLvColum1.MaxWidth = self._lvculomwidth
self.FormLvColum2.MaxWidth = self._lvculomwidth |
or even trying to get the width
Code: | self.FormLvColum1.getWidth()
self.FormLvColum2.getWidth() |
When I call the getWidth() function it returns me this
Code: | attempt to call field 'getWidth' (a nil value)
Script Error |
Am I doing something wrong?
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Thu Jul 18, 2013 9:19 am Post subject: |
|
|
Oops, looks like I messed up the method names for column
I accidentally left them to listcolumn_getWidth (do NOT use this, I will change it to getWidth next version)
Luckily the Properties do work (Which are recommended over the methods anyhow)
Also .Width= does work
e.g:
Code: |
self.FormLvColum1.Width=100
|
does work for me (it sets it to 100 width)
tested with this code works as well:
Code: |
self={}
self.MainForm=createForm(true)
self._lvculomnwidth=100
self.FormLv = createListView(self.MainForm)
setProperty(self.FormLv, 'ViewStyle', 'vsReport')
setProperty(self.FormLv, 'RowSelect', 'True')
setProperty(self.FormLv, 'ReadOnly', 'True')
self.FormLv.height = 200
self.FormLv.width = 300
self.FormLvC = self.FormLv.getColumns()
self.FormLvColum1 = self.FormLvC.add()
self.FormLvColum2 = self.FormLvC.add()
self.FormLvColum1.Caption = self._lvc1caption
self.FormLvColum2.Caption = self._lvc2caption
self.FormLvColum1.Width=self._lvculomnwidth
self.FormLvColum2.Width=self._lvculomnwidth
|
note that I initialized self._lvculomnwidth NOT self._lvcolumnwidth...
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Thu Jul 18, 2013 10:34 am Post subject: |
|
|
Cant double post so I deleted the post and re-post.
How can I add an item to the list view?
I'm doing this:
Code: |
function EasyFormAccess:Start()
--..
self.FormLvI = self.FormLv.getItems()
--....
end
function EasyFormAccess:AddItems(FormCaption)
local Temp
Temp = self.FormLvI.add()
Temp.caption = FormCaption
end
function EasyFormAccess:Initialize()
for i = 1,#GlobalFormTable do
self:AddItems(GlobalFormTable[i].caption)
end
end |
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Thu Jul 18, 2013 10:40 am Post subject: |
|
|
use Caption instead of caption
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Thu Jul 18, 2013 10:43 am Post subject: |
|
|
The caption is not the problem.
It just won't create any 'item' in the listview.
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Thu Jul 18, 2013 11:11 am Post subject: |
|
|
You're sure it doesn't add an item?
this works
Code: |
self={}
self.MainForm=createForm(true)
self._lvculomnwidth=100
self.FormLv = createListView(self.MainForm)
setProperty(self.FormLv, 'ViewStyle', 'vsReport')
setProperty(self.FormLv, 'RowSelect', 'True')
setProperty(self.FormLv, 'ReadOnly', 'True')
self.FormLv.height = 200
self.FormLv.width = 300
self.FormLvC = self.FormLv.getColumns()
self.FormLvColum1 = self.FormLvC.add()
self.FormLvColum2 = self.FormLvC.add()
self.FormLvColum1.Caption = self._lvc1caption
self.FormLvColum2.Caption = self._lvc2caption
self.FormLvColum1.Width=self._lvculomnwidth
self.FormLvColum2.Width=self._lvculomnwidth
self.FormLvI=self.FormLv.getItems()
x=self.FormLvI.add()
x.Caption="bla"
|
pehaps #GlobalFormTable returns 0
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Thu Jul 18, 2013 12:05 pm Post subject: |
|
|
Oh sorry, I found my issue.
Setting OnClick function works ONLY if I use it as self.function, while the original function is self:function.
(Self = table name).
To get around it, just made a new function for these buttons who call the self:function()...
Anyway, everything works great, almost finished.
Just last question.
How can I show a form based the ListView index.
I mean, I can show/hide easily with ListBox,
But in ListView, the index resets back to -1 when it loses focus.
How can I keep the index the way it is without allow it to reset? (Like in listbox)
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Thu Jul 18, 2013 12:53 pm Post subject: |
|
|
Are you sure the index resets to -1 or just becomes invisible (index value stays)
anyhow, assuming you mean invisible , set the property "HideSelection" to false (default is true)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
|
Back to top |
|
|
|