Sign in to follow this  
Followers 0
bab

Help with List from inifile

4 posts in this topic

Would someone mind helping me. I created an inifile,called servers.ini. Sample contents of the file:

[servers]

1=myserver1

2=myserver2

3=myserver3

4=myserver4

I am reading the file into an array. I want to create a menu to display the list of servers. Once the app is completed, a server will be selected and something will be performed on the server. I need to know how to display just the server names in the list view and not the keys (1,2,3,4, etc. Here's my code: thanks. The code below returns both columns. I just want to see the column with myserver1, myserver2, etc.

#include <GUIConstants.au3>

#include <GUIListBox.au3>

#include <GuiListView.au3>

#include <Process.au3>

include <constants.au3>

#include <array.au3>

AutoItSetOption ("ExpandVarStrings" , 1)

Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

Dim $srvlst

$mnuapp = GUICreate("Servers" , 400, 500,-1, -1, -1, 0x00000018); WS_EX_ACCEPTFILES

$listview = _GUICtrlListView_Create ($mnuapp,"", 10, 32, 300, 197)

_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)

GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling

GUICtrlSetData(-1, "")

GUISetState()

$srvlst = IniReadSection("servers.ini", "Servers")

_GUICtrlListView_AddColumn($listview, "Servers", 120)

_GUICtrlListView_AddArray ($listview, $srvlst)

_GUICtrlListView_SetItemSelected($listview, 0)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstants.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <Process.au3>
#include <constants.au3>
#include <array.au3>

AutoItSetOption ("ExpandVarStrings" , 1)
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
Dim $srvlst
$mnuapp = GUICreate("Servers" , 400, 500,-1, -1, -1, 0x00000018); WS_EX_ACCEPTFILES

$listview = _GUICtrlListView_Create ($mnuapp, 'Servers', 10, 32, 300, 197)
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)

GUICtrlSetLimit(-1, 200)
GUICtrlSetData(-1, "")
GUISetState()
$srvlst = IniReadSection("servers.ini", "Servers")
If @error Then
    MsgBox(16, 'Error', 'Unable to read section "Servers" in "servers.ini"')
    Exit
EndIf

For $i = 1 To $srvlst[0][0] Step +1
    _GUICtrlListView_AddItem($listview, $srvlst[$i][1])
Next
_GUICtrlListView_SetItemSelected($listview, 0)

Edited by dwerf

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <Process.au3>
#include <constants.au3>
#include <array.au3>

AutoItSetOption ("ExpandVarStrings" , 1)
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
Dim $srvlst
$mnuapp = GUICreate("Servers" , 400, 500,-1, -1, -1, 0x00000018); WS_EX_ACCEPTFILES

$listview = _GUICtrlListView_Create ($mnuapp, 'Servers', 10, 32, 300, 197)
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)

GUICtrlSetLimit(-1, 200)
GUICtrlSetData(-1, "")
GUISetState()
$srvlst = IniReadSection("servers.ini", "Servers")
If @error Then
    MsgBox(16, 'Error', 'Unable to read section "Servers" in "servers.ini"')
    Exit
EndIf

For $i = 1 To $srvlst[0][0] Step +1
    _GUICtrlListView_AddItem($listview, $srvlst[$i][1])
Next
_GUICtrlListView_SetItemSelected($listview, 0)

Share this post


Link to post
Share on other sites

Thank You so much. I was at a stand still. Greatly appreciated.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0