Jump to content

[GUI] Gridlist


Recommended Posts

Hey Guys,

I made a simple GUI with an Gridlist. The Gridlist has just one Coloumn. With a commandhandler i add some rows in this coloumn. This works fine but i want to scoll automaticly to the last row... I tested the guiGridListSetHorizontalScrollPosition and the guiGridListSetVerticalScrollPosition but it wont work... I got the last Index by counting all rows with GuiGridListGetRowCount. Pleas help :( A Example would be nice :)

Link to comment
  
function addText(List, column, text) 
    local row = guiGridListAddRow ( List ) 
    guiGridListSetItemText ( List, row, column, text, false, false ) 
     
    local rowCount = guiGridListGetRowCount (List) 
     
    guiGridListSetHorizontalScrollPosition( List, rowCount ) 
     
end 
  
function createList () 
    local List = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    local column = guiGridListAddColumn( List, "Infos", 0.85 ) 
    if ( column ) then 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
    end 
end 
  

just a sample of my problem

Link to comment
Today I tried to use the guiGridListSetVerticalScrollPosition function, but it doesn't seem to be working.

The scroll position can be set between 0 and 100, but the function is bugged or what... so it sets the position wrong.

i've got that problem before and i've fixed it by just using a timer with 50 ms for every guiGridListSetVerticalScrollPosition execution like this:

setTimer(guiGridListSetVerticalScrollPosition, 50, 1, gridlist, 100) 

function addText(List, column, text) 
    local row = guiGridListAddRow ( List ) 
    guiGridListSetItemText ( List, row, column, text, false, false ) 
     
    local rowCount = guiGridListGetRowCount (List) 
     
    guiGridListSetHorizontalScrollPosition( List, rowCount ) 
     
end 
  
function createList () 
    local List = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    local column = guiGridListAddColumn( List, "Infos", 0.85 ) 
    if ( column ) then 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
    end 
end 

just a sample of my problem

Here you go

function addText(List, column, text) 
    local row = guiGridListAddRow ( List ) 
    guiGridListSetItemText ( List, row, column, text, false, false ) 
    local rowCount = guiGridListGetRowCount (List) 
    setTimer ( guiGridListSetHorizontalScrollPosition, 50, 1, List, 100 ) 
     
end 
  
function createList () 
    local List = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    local column = guiGridListAddColumn( List, "Infos", 0.85 ) 
    if ( column ) then 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
        addText(List, column, "Test") 
    end 
end 

Link to comment
  
local messageBoxVisible = true 
  
newMessageBoxGui = { 
    gridlist = {}, 
    window = {} 
} 
  
  
function toggleNewWindowVisible() 
    if (messageBoxVisible == true) then 
        guiSetVisible(newMessageBoxGui.window[1], false) 
        messageBoxVisible = false 
    else 
        guiSetVisible(newMessageBoxGui.window[1], true) 
        messageBoxVisible = true 
    end 
end 
  
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        newMessageBoxGui.window[1] = guiCreateWindow(0.33, 0.00, 0.33, 0.15, "", true) 
        guiWindowSetSizable(newMessageBoxGui.window[1], false) 
        guiSetAlpha(newMessageBoxGui.window[1], 0.59) 
  
        newMessageBoxGui.gridlist[1] = guiCreateGridList(0.03, 0.17, 0.94, 0.76, true, newMessageBoxGui.window[1])  
         
        column = guiGridListAddColumn( newMessageBoxGui.gridlist[1], "", 0.85 ) 
        if ( column ) then 
            row = guiGridListAddRow ( newMessageBoxGui.gridlist[1] ) 
            guiGridListSetItemText ( newMessageBoxGui.gridlist[1], row, column, "Willkommen auf ATV - Reallife", false, false ) 
        end 
         
        guiSetVisible(newMessageBoxGui.window[1], true) 
        addNewMessage("LOL") 
        addNewMessage("hallo") 
        addNewMessage("LOL") 
        addNewMessage("LOL") 
        addNewMessage("ROFL") 
        addNewMessage("LOL") 
        addNewMessage("hallo") 
        addNewMessage("LOL") 
        addNewMessage("LOL") 
        addNewMessage("ROFL") 
        addNewMessage("LOL") 
        addNewMessage("hallo") 
        addNewMessage("LOL") 
        addNewMessage("LOL") 
        addNewMessage("ROFL") 
        bindKey("o", "down", toggleNewWindowVisible) 
         
         
    end 
) 
  
function addNewMessage(message) 
    local row = guiGridListAddRow ( newMessageBoxGui.gridlist[1] ) 
    guiGridListSetItemText ( newMessageBoxGui.gridlist[1], row, column, message, false, false ) 
    local rowCount = guiGridListGetRowCount ( newMessageBoxGui.gridlist[1] ) 
    setTimer ( guiGridListSetHorizontalScrollPosition, 50, 1, newMessageBoxGui.gridlist[1], 100 ) 
end 
  
  
  

Don`t work ...

Link to comment

The problem is that you are setting the HORIZONTAL position, not the VERTICAL position.

local messageBoxVisible = true 
  
newMessageBoxGui = { 
    gridlist = {}, 
    window = {} 
} 
  
  
function toggleNewWindowVisible() 
    if (messageBoxVisible == true) then 
        guiSetVisible(newMessageBoxGui.window[1], false) 
        messageBoxVisible = false 
    else 
        guiSetVisible(newMessageBoxGui.window[1], true) 
        messageBoxVisible = true 
    end 
end 
  
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        newMessageBoxGui.window[1] = guiCreateWindow(0.33, 0.00, 0.33, 0.15, "", true) 
        guiWindowSetSizable(newMessageBoxGui.window[1], false) 
        guiSetAlpha(newMessageBoxGui.window[1], 0.59) 
  
        newMessageBoxGui.gridlist[1] = guiCreateGridList(0.03, 0.17, 0.94, 0.76, true, newMessageBoxGui.window[1]) 
        
        column = guiGridListAddColumn( newMessageBoxGui.gridlist[1], "", 0.85 ) 
        if ( column ) then 
            row = guiGridListAddRow ( newMessageBoxGui.gridlist[1] ) 
            guiGridListSetItemText ( newMessageBoxGui.gridlist[1], row, column, "Willkommen auf ATV - Reallife", false, false ) 
        end 
        
        guiSetVisible(newMessageBoxGui.window[1], true) 
        addNewMessage("LOL") 
        addNewMessage("hallo") 
        addNewMessage("LOL") 
        addNewMessage("LOL") 
        addNewMessage("ROFL") 
        addNewMessage("LOL") 
        addNewMessage("hallo") 
        addNewMessage("LOL") 
        addNewMessage("LOL") 
        addNewMessage("ROFL") 
        addNewMessage("LOL") 
        addNewMessage("hallo") 
        addNewMessage("LOL") 
        addNewMessage("LOL") 
        addNewMessage("ROFL") 
        bindKey("o", "down", toggleNewWindowVisible) 
    end 
) 
  
function addNewMessage(message) 
    local row = guiGridListAddRow ( newMessageBoxGui.gridlist[1] ) 
    guiGridListSetItemText ( newMessageBoxGui.gridlist[1], row, column, message, false, false ) 
    local rowCount = guiGridListGetRowCount ( newMessageBoxGui.gridlist[1] ) 
    setTimer ( guiGridListSetVerticalScrollPosition, 50, 1, newMessageBoxGui.gridlist[1], 100 ) 
end 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...