Sign in to follow this  
Followers 0
llewxam

[SOLVED] ListView SubItem destroying preceding zeroes

7 posts in this topic

#1 ·  Posted (edited)

I am pretty new to using ListViews, and while I really dig them, one just screwed me over pretty badly :)

I wrote an inventory manager app for my shop, and I used to use a ListBox tgo display the item brand and description, and had several labels throughout the GUI for price, UPC, etc. I have recently re-written it using a ListView and it simplified things considerably. BUT, today my warehouse manager came to me and said the Edit feature was broken, and that items with UPCs starting with a zero were not showing that initial zero. I checked it and tried a few things such as making it a string, but the initial zero is still being trimmed automatically. Anyone have any ideas on how to prevent this??

Below is a stripped-down test version which inserts some (fake) items to demonstrate it. Any help would be greatly appreciated!!

Ian

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>

$GUI = GUICreate("Inventory Manager", 720, 460)
GUISetBkColor(0xb2ccff, $GUI)
$Items = _GUICtrlListView_Create($GUI, "", 10, 40, 700, 350)
_GUICtrlListView_SetExtendedListViewStyle($Items, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_AddColumn($Items, "Brand/Model")
_GUICtrlListView_AddColumn($Items, "UPC")
_GUICtrlListView_AddColumn($Items, "Price")
_GUICtrlListView_SetColumnWidth($Items, 0, 460)
_GUICtrlListView_SetColumnWidth($Items, 1, 130)
_GUICtrlListView_SetColumnWidth($Items, 2, 93)
$addItem = GUICtrlCreateButton("&Add Item", 465, 10, 75, 25)
$deleteItem = GUICtrlCreateButton("&Delete Item", 550, 10, 75, 25)
$editItem = GUICtrlCreateButton("&Edit Item", 635, 10, 75, 25)
$generalSearchInput = GUICtrlCreateInput("", 10, 400, 160, 21)
$generalSearchButton = GUICtrlCreateButton("Search (ENTER)", 9, 425, 162, 25, 0)
$showAllItems = GUICtrlCreateButton("&Show All Items", 174, 399, 86, 51)
$TrackButton = GUICtrlCreateButton("Track Item Sales", 345, 409, 125, 27)
$itemCount = GUICtrlCreateLabel("", 50, 10, 50, 18)
GUICtrlSetFont(-1, 10)
GUICtrlSetBkColor($itemCount, "0xffffff")
GUICtrlCreateLabel("Items:", 10, 11, 32, 25)
GUICtrlSetFont(-1, 10)
GUISetFont(12)
GUISetState(@SW_SHOW, $GUI)


_GUICtrlListView_BeginUpdate($Items)

_GUICtrlListView_AddItem($Items, "Microsoft Mouse and Keyboard Combo", 0)
_GUICtrlListView_AddSubItem($Items, 0, 212345432345, 1)
_GUICtrlListView_AddSubItem($Items, 0, "$34.99", 2)

_GUICtrlListView_AddItem($Items, "Antec Universal Laptop Adapter", 0)
_GUICtrlListView_AddSubItem($Items, 1, 212342132345, 1)
_GUICtrlListView_AddSubItem($Items, 1, "$49.00", 2)

_GUICtrlListView_AddItem($Items, "Gear Head Wireless Mouse", 0)
_GUICtrlListView_AddSubItem($Items, 2, String(012342132345), 1)
_GUICtrlListView_AddSubItem($Items, 2, "$19.50", 2)

_GUICtrlListView_EndUpdate($Items)


Do

    $MSG = GUIGetMsg()
    If $MSG = $GUI_EVENT_CLOSE Then Exit
Until 1 = 2
Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites



Try to replace 212345432345 with "0212345432345".

You are absolutely right for the above example so thanks, BUT, the UPC is coming as a variable. So, I guess an addendum to the sample code would be:

$UPC=012342132345
_GUICtrlListView_AddItem($Items, "Gear Head Wireless Mouse", 0)
_GUICtrlListView_AddSubItem($Items, 2, $UPC, 1)
_GUICtrlListView_AddSubItem($Items, 2, "$19.50", 2)

Thanks

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Ian, if your $UPC is 12 characters long and want to have leading zero's, use this:

$UPC = 123456
$UPC=StringFormat("%012s",$UPC)

Regards,

taietel

[EDIT]

Edited by taietel

Share this post


Link to post
Share on other sites

Ian, if your $UPC is 12 characters long and want to have leading zero's, use this:

$UPC = 123456
$UPC=StringFormat("%012s",$UPC)

Regards,

taietel

[EDIT]

geez, the plot thickens.....

Both suggestions based on StringFormat you gave are correct, and I had already tried StringFormat but the 0 kept getting cut, I assumed it was the ListView itself doing it. BUT it isn't, I just turned off the _GUICtrlListView_SimpleSort that I use so my items are sorted right (because nothing was working!!) and now the UPCs are not getting cut. SO, now it is time to try other options like GUICtrlRegisterListViewSort..............

THANKS again, hopefully I will add a big-ole {SOLVED} soon.... :)

Ian


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

Fixed by modifying GuiListView.au3, changed _GUICtrlListView_SimpleSort by commenting out

If (StringIsFloat($v_item) Or StringIsInt($v_item)) Then
    $a_lv[$x][$Y] = Number($v_item)
Else
    $a_lv[$x][$Y] = $v_item
EndIf
$a_lv[$x][$Y] = $v_item

and just using the last line. The Number function was doing the trimming, I have used that before intentionally, this time it bit me! :)

Thanks for your help taietel!

Ian

BTW, I love your 3D Graphing UDF, I use it in this same inventory app for sales tracking :)


My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.

Share this post


Link to post
Share on other sites

I'm glad you solved the problem!

Also glad to hear about that UDF. Those functions (slightly modified) I use them to output the results in pdf format. BTW, I have modified the UDF for pdf creation: there's no need to include fonts anymore (thus, the final script is smaller). I will post the modified version as soon as possible (need to do some more changes).

Regards,

taietel

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