STINGX Posted December 26, 2022 Share Posted December 26, 2022 (edited) function dxGridList( x, y, w, h, parent) local self, element = createElement( 'dxGridList', parent, sourceResource ) if self then self.x = math.round(x) self.y = math.round(y) self.w = math.round(w) self.h = math.round(h) self.parent = parent self.colorbackground = tocolor( 20, 20, 30, 255 ) self.colortext = tocolor(255, 255, 255, 255) self.colorselected = tocolor(120, 95, 205, 255) if self.parent then self.offsetX = self.x - Cache[self.parent].x self.offsetY = self.y - Cache[self.parent].y end self.font = Files['font']['Basic-Regular'][10] self.fontH = dxGetFontHeight( 1, self.font ) -- self.scrollV = dxScroll(self.x+self.w-math.round(17*sh), self.y, self.h, true, parent) self.scrollH = dxScroll(self.x, self.y+self.h-math.round(17*sh), self.w-math.round(17*sh), false, parent) Cache[self.scrollH].isVisible = false Cache[self.scrollV].isVisible = false Cache[self.scrollV].gridlist = element self.from = nil self.to = nil self.mul = 0 self.columns = {} self.items = {} self.scrollX = 0 self.scrollY = 0 -- self.selected = -1 self.update = true Timer(function() self.update = true end, 600, 1) Timer(function() self.update = true end, 1200, 1) return element end end function dxGridListAddItem(element, ...) local self = Cache[element] if self then table.insert(self.items, {...}) self.update2 = true return true end return false end function dxGridListRemoveItem(element, index) local self = Cache[element] if self then if self.items[index] then table.remove(self.items, index) self.update2 = true return true end end return false end function dxGridListAddColumn(element, name, size) local self = Cache[element] if self then table.insert(self.columns, {name, size}) self.update = true return name end return false end -------- My Code function dxGridListSetItemText(element, columns, name) if self.items[columns] and self.items[columns][element] then self.items[columns][element].text = text end end How can i make setItemText for this grid , i tryed but it's not work. Edited December 26, 2022 by STINGX Link to comment
Shady1 Posted December 26, 2022 Share Posted December 26, 2022 3 minutes ago, STINGX said: function dxGridList( x, y, w, h, parent) local self, element = createElement( 'dxGridList', parent, sourceResource ) if self then self.x = math.round(x) self.y = math.round(y) self.w = math.round(w) self.h = math.round(h) self.parent = parent self.colorbackground = tocolor( 20, 20, 30, 255 ) self.colortext = tocolor(255, 255, 255, 255) self.colorselected = tocolor(120, 95, 205, 255) if self.parent then self.offsetX = self.x - Cache[self.parent].x self.offsetY = self.y - Cache[self.parent].y end self.font = Files['font']['Basic-Regular'][10] self.fontH = dxGetFontHeight( 1, self.font ) -- self.scrollV = dxScroll(self.x+self.w-math.round(17*sh), self.y, self.h, true, parent) self.scrollH = dxScroll(self.x, self.y+self.h-math.round(17*sh), self.w-math.round(17*sh), false, parent) Cache[self.scrollH].isVisible = false Cache[self.scrollV].isVisible = false Cache[self.scrollV].gridlist = element self.from = nil self.to = nil self.mul = 0 self.columns = {} self.items = {} self.scrollX = 0 self.scrollY = 0 -- self.selected = -1 self.update = true Timer(function() self.update = true end, 600, 1) Timer(function() self.update = true end, 1200, 1) return element end end function dxGridListAddItem(element, ...) local self = Cache[element] if self then table.insert(self.items, {...}) self.update2 = true return true end return false end function dxGridListRemoveItem(element, index) local self = Cache[element] if self then if self.items[index] then table.remove(self.items, index) self.update2 = true return true end end return false end function dxGridListAddColumn(element, name, size) local self = Cache[element] if self then table.insert(self.columns, {name, size}) self.update = true return name end return false end -------- My Code function dxGridListSetItemText(element, columns, name) if self.items[columns] and self.items[columns][element] then self.items[columns][element].text = text end end How can i make setItemText for this grid , i tryed but it's not work. hello welcome to the forum, if you explain your problem in a more descriptive way we can help you,For example, you can explain the problems in debugscript 3 side, or you can explain a little what exactly is the problem. Link to comment
STINGX Posted December 26, 2022 Author Share Posted December 26, 2022 (edited) 5 minutes ago, Shady1 said: hello welcome to the forum, if you explain your problem in a more descriptive way we can help you,For example, you can explain the problems in debugscript 3 side, or you can explain a little what exactly is the problem. I'm trying to make dxGridListSetItemText like guiGridListSetItemText to change text in my gridlist lib and this my code ...... function dxGridListSetItemText(element, columns, name) if self.items[columns] and self.items[columns][element] then self.items[columns][element].text = text end end Edited December 26, 2022 by STINGX Link to comment
Shady1 Posted December 26, 2022 Share Posted December 26, 2022 9 minutes ago, STINGX said: I'm trying to make dxGridListSetItemText like guiGridListSetItemText to change text in my gridlist lib and this my code ...... function dxGridListSetItemText(element, columns, name) if self.items[columns] and self.items[columns][element] then self.items[columns][element].text = text end end hmm, you can try the code i will send you and don't forget you should check debug... function dxGridListSetItemText(element, columns, name) outputDebugString(tostring(self.items[columns])) --add debug lines outputDebugString(tostring(self.items[columns][element])) if self.items[columns] and self.items[columns][element] then self.items[columns][element].text = text end end Link to comment
STINGX Posted December 26, 2022 Author Share Posted December 26, 2022 33 minutes ago, Shady1 said: hmm, you can try the code i will send you and don't forget you should check debug... function dxGridListSetItemText(element, columns, name) outputDebugString(tostring(self.items[columns])) --add debug lines outputDebugString(tostring(self.items[columns][element])) if self.items[columns] and self.items[columns][element] then self.items[columns][element].text = text end end Quote https://imgur.com/YA5LPzm my test code in panel dxGridListSetItemText(list2, 1, "1") Link to comment
STINGX Posted December 26, 2022 Author Share Posted December 26, 2022 54 minutes ago, STINGX said: my test code in panel dxGridListSetItemText(list2, 1, "1") edited ... ? https://imgur.com/xAqXf9X Link to comment
STINGX Posted December 27, 2022 Author Share Posted December 27, 2022 22 hours ago, STINGX said: edited ... ? https://imgur.com/xAqXf9X any help Link to comment
Trust aka Tiffergan Posted December 30, 2022 Share Posted December 30, 2022 On 27/12/2022 at 19:57, STINGX said: any help To set the text of an item in a grid list created with the above code, you will need to modify the dxGridListSetItemText function as follows: First, you will need to modify the function definition to accept the element, column, and row indices as arguments, as well as the new text for the item. Here is an example of how you can do this: function dxGridListSetItemText(element, column, row, text) Next, you will need to retrieve the grid list element from the cache using the Cache table, as shown in the other functions: local self = Cache[element] Once you have the grid list element, you can access the items in the grid list using the self.items table. To set the text of an item, you will need to index into this table using the column and row indices passed to the function. Here is an example of how you can do this: self.items[row][column].text = text Finally, you may need to set the update2 flag to true to trigger a redraw of the grid list. This will ensure that the changes to the item text are displayed in the game. function dxGridListSetItemText(element, column, row, text) local self = Cache[element] if self then if self.items[row] and self.items[row][column] then self.items[row][column].text = text self.update2 = true return true end end return false end I hope this helps! Let me know if you have any questions Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now