T1TAN23
Member
Hi all,
I am writing a touch screen application and I have hit a snag that I can not figure out. The gest of the application is that a user can use a bar code scanner to scan items into and out of inventory and I have one peice that will allow the user to search via part number, Description, or partial bar code. The problem I am having is that when they decide they need to search and click on the Search button, I open a new form and give them a text box to type into, once they click on search I populate a listview in that same form, when they click on a item in that list view I then add that item to a global array which populates the Main listview of items being checked in/ out of inventory. The Item selected gets added to the array but does not show in the main listview until the next item is scanned.
How do I update the listview from the other form?
This adds and Item to the main list view (located in frmInventory)
This is the UpdateList() call made from the AddItems method (located in frmInventory)
This is the listview click located on the newly opend form frmSearch
As I said before I know the selected item gets added to the array because it shows up in the list after another Item has been scanned.
So far I have tried to call lsvSearch.Update and lsvSearch.refresh from the lsvSearch_Click. I tried adding a listener in frmInventory to listen for frmSearch to close then call the UpdateList(), and several other failed attempts and nothing seems to work.
Thanks in advance for any help.
I am writing a touch screen application and I have hit a snag that I can not figure out. The gest of the application is that a user can use a bar code scanner to scan items into and out of inventory and I have one peice that will allow the user to search via part number, Description, or partial bar code. The problem I am having is that when they decide they need to search and click on the Search button, I open a new form and give them a text box to type into, once they click on search I populate a listview in that same form, when they click on a item in that list view I then add that item to a global array which populates the Main listview of items being checked in/ out of inventory. The Item selected gets added to the array but does not show in the main listview until the next item is scanned.
How do I update the listview from the other form?
This adds and Item to the main list view (located in frmInventory)
VB.NET:
[SIZE=2][COLOR=#008000]'Adds items to the Global arItems Array[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] AddItems([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] intItemID [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] intQty [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] j [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] blnFound [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Boolean[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2]i = UBound(arItems, 2)[/SIZE]
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] j = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] UBound(arItems, 2)[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] arItems(0, j) = intItemID [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]blnFound = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] blnFound = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'If the ItemID already exists then update the qty + 1[/COLOR][/SIZE]
[SIZE=2]arItems(2, j) = arItems(2, j) + 1[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].UpdateList()[/SIZE]
[SIZE=2]Speech(ReturnDescription(intItemID))[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Add the 1st Item to the Array[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] arItems(0, 0) = "" [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]arItems(0, i) = intItemID[/SIZE]
[SIZE=2]arItems(1, i) = ReturnDescription(intItemID)[/SIZE]
[SIZE=2]arItems(2, i) = intQty[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].UpdateList()[/SIZE]
[SIZE=2]Speech(ReturnDescription(intItemID))[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Add new items to the array[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]ReDim[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Preserve[/COLOR][/SIZE][SIZE=2] arItems(2, i + 1)[/SIZE]
[SIZE=2]arItems(0, i + 1) = intItemID[/SIZE]
[SIZE=2]arItems(1, i + 1) = ReturnDescription(intItemID)[/SIZE]
[SIZE=2]arItems(2, i + 1) = intQty[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].UpdateList()[/SIZE]
[SIZE=2]Speech(ReturnDescription(intItemID))[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'reset the txtBarcode[/COLOR][/SIZE]
[SIZE=2]txtBarCode.Text = ""[/SIZE]
[SIZE=2]txtBarCode.Focus()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
This is the UpdateList() call made from the AddItems method (located in frmInventory)
VB.NET:
[SIZE=2][COLOR=#008000]'Updates the lsvItems ListView Control by clearing the ListView Control[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'and then adding everything back in from the Global Array arItems[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] UpdateList()[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] str(1) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] itm [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ListViewItem[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2]lsvItems.Items.Clear()[/SIZE]
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] i = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] UBound(arItems, 2)[/SIZE]
[SIZE=2]str(0) = arItems(1, i)[/SIZE]
[SIZE=2]str(1) = arItems(2, i)[/SIZE]
[SIZE=2]itm = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ListViewItem(str)[/SIZE]
[SIZE=2]lsvItems.Items.Add(itm)[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Refresh()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
This is the listview click located on the newly opend form frmSearch
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] lsvSearch_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] lsvSearch.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] frm1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] frmInventory[/SIZE]
[SIZE=2]txtSearch.Text = ""[/SIZE]
[SIZE=2]txtSearch.Text = lsvSearch.SelectedItems(0).Text & ";" & lsvSearch.SelectedItems(0).SubItems(1).Text[/SIZE]
[SIZE=2]frm1.AddItems(lsvSearch.SelectedItems(0).SubItems(1).Text, 1)[/SIZE]
[SIZE=2]frm1.lsvItems.Update()[/SIZE]
[SIZE=2]blnNewForm = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
As I said before I know the selected item gets added to the array because it shows up in the list after another Item has been scanned.
So far I have tried to call lsvSearch.Update and lsvSearch.refresh from the lsvSearch_Click. I tried adding a listener in frmInventory to listen for frmSearch to close then call the UpdateList(), and several other failed attempts and nothing seems to work.
Thanks in advance for any help.