Jump to content

[GUI] Gridlist


Recommended Posts

Posted

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 :)

Known Languages:

[LUA][VB.NET][ASP.NET][C#][JAVA][C++]

[sqlite][MSSQL][salesForce][bATCH][/center]
Posted

Okey when i`m at home ill post my problem script but i think my description of the problem must be enough to know what the problem is or not?

Known Languages:

[LUA][VB.NET][ASP.NET][C#][JAVA][C++]

[sqlite][MSSQL][salesForce][bATCH][/center]
Posted
  
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

Known Languages:

[LUA][VB.NET][ASP.NET][C#][JAVA][C++]

[sqlite][MSSQL][salesForce][bATCH][/center]
Posted
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 

F4MZM4.gif

Posted

Okey i'll test it as soon as possible

Known Languages:

[LUA][VB.NET][ASP.NET][C#][JAVA][C++]

[sqlite][MSSQL][salesForce][bATCH][/center]
Posted

@Tete omar: Yes, with the timer it should work ( It worked for me with onClientRender ) because it sets the correct position but then for some reason it jumps back.

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted
  
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 ...

Known Languages:

[LUA][VB.NET][ASP.NET][C#][JAVA][C++]

[sqlite][MSSQL][salesForce][bATCH][/center]
Posted

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Ok I`ll test it as soon as possbile

Known Languages:

[LUA][VB.NET][ASP.NET][C#][JAVA][C++]

[sqlite][MSSQL][salesForce][bATCH][/center]
Posted

I've tested it before posting it and it worked fine.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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...