|
-
May 8th, 2013, 09:27 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Passing checked items/process to other form
Hi,
Anyone can help, pass all checked listview items into my install form??
And then start process in install form... Here's what I have:
Code:
If ListView1.CheckedItems.Count > 0 Then
For Each Item As ListViewItem In ListView1.CheckedItems
'//Install
'install = lVI.Checked
Next
Me.Hide()
InstallPrograms.Show()
Else
MessageBox.Show("Nothing selected to install!")
End If
-
May 8th, 2013, 09:48 AM
#2
Addicted Member
Re: Passing checked items/process to other form
Just a suggestion, there could be other ways. But I had a similar problem last time and was recommended something like this.
Create a module with a class of booleans for each install checkbox.
If the checkbox is checked change that boolean to True.
vb.net Code:
Module Module2
Public setting As New installsettings
Public Class installsettings
Public Property var1 As Boolean
Public Property var2 As Boolean
Public Property var3 As Boolean
Public Property var4 As Boolean
End Class
End Module
Then for each check box do something like this
vb.net Code:
Private Sub chkvar1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chkvar1.CheckedChanged
if chkvar1.Checked = True then
setting.var1 = True
else
settings.var1 = False
End if
End Sub
Then in your install Form you can access them like this
vb.net Code:
if settings.var1 = true then
'Install var1....
End if
-
May 8th, 2013, 10:12 AM
#3
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
So you're saying to replace all this:
Code:
Public Class InstallPrograms
Dim pCount As Integer
Dim p() As Process
Dim inifile As String = Application.StartupPath + "/Start/InstallCFG.ini"
Dim stream_reader As New IO.StreamReader(iniFile)
Dim line As String
Dim ReadResult() As String
Sub Form1_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MyBase.KeyUp
If e.KeyData = Keys.F1 Then
Editor.ShowDialog()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
line = stream_reader.ReadLine() 'Read InstallCFG.ini File
Do While Not (line Is Nothing)
ReadResult = line.Split(":") 'Split line at :
If (ReadResult(0).ToLower() = "prog name") Then
Label3.Text = "Installing " + ReadResult(1)
End If
If (ReadResult(0).ToLower() = "installer file") Then
PictureBox1.ImageLocation = ".\images\System-Working.gif"
Label3.Refresh()
Label5.Refresh()
Dim info As New System.Diagnostics.ProcessStartInfo
info.FileName = ReadResult(1) 'Open the application
Dim myProcess As New System.Diagnostics.Process
myProcess.StartInfo = info
myProcess.Start() 'Start the process
myProcess.WaitForExit() 'Wait until the process started is finished
myProcess.Close() 'Release the resources
Label5.Text = "Install Complete..."
Label5.Refresh()
System.Threading.Thread.Sleep(750)
Label5.Text = ""
Label5.Refresh()
Else
MessageBox.Show("Something is wrong! File = " & ReadResult(1))
End If
line = stream_reader.ReadLine() 'Move on to the next line.
Loop
stream_reader.Close()
' We'll assume you have all the filepaths in a listbox
' it would work the same for any other collection type
pCount = ListBox1.Items.Count
ReDim p(pCount - 1)
For i = 0 To pCount - 1
p(i) = New Process With {.EnableRaisingEvents = True}
AddHandler p(i).Exited, AddressOf ProcessExit
p(i).StartInfo.FileName = ListBox1.Items(i).ToString
p(i).Start()
Next
End Sub
Private Sub ProcessExit(ByVal sender As Object, ByVal e As System.EventArgs)
pCount -= 1
If pCount = 0 Then
MsgBox("All Done")
End If
End Sub
End Class-
with ur code......
-
May 8th, 2013, 10:24 AM
#4
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
Sorry, got ya... That's not good m8, as i'm reading from a .ini file, can be any amount of installs 10+/20+/30+/40+/80+/100+
-
May 8th, 2013, 10:27 AM
#5
Addicted Member
Re: Passing checked items/process to other form
 Originally Posted by chris-2k
So you're saying to replace all this:
Code:
Public Class InstallPrograms
Dim pCount As Integer
Dim p() As Process
Dim inifile As String = Application.StartupPath + "/Start/InstallCFG.ini"
Dim stream_reader As New IO.StreamReader(iniFile)
Dim line As String
Dim ReadResult() As String
Sub Form1_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MyBase.KeyUp
If e.KeyData = Keys.F1 Then
Editor.ShowDialog()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
line = stream_reader.ReadLine() 'Read InstallCFG.ini File
Do While Not (line Is Nothing)
ReadResult = line.Split(":") 'Split line at :
If (ReadResult(0).ToLower() = "prog name") Then
Label3.Text = "Installing " + ReadResult(1)
End If
If (ReadResult(0).ToLower() = "installer file") Then
PictureBox1.ImageLocation = ".\images\System-Working.gif"
Label3.Refresh()
Label5.Refresh()
Dim info As New System.Diagnostics.ProcessStartInfo
info.FileName = ReadResult(1) 'Open the application
Dim myProcess As New System.Diagnostics.Process
myProcess.StartInfo = info
myProcess.Start() 'Start the process
myProcess.WaitForExit() 'Wait until the process started is finished
myProcess.Close() 'Release the resources
Label5.Text = "Install Complete..."
Label5.Refresh()
System.Threading.Thread.Sleep(750)
Label5.Text = ""
Label5.Refresh()
Else
MessageBox.Show("Something is wrong! File = " & ReadResult(1))
End If
line = stream_reader.ReadLine() 'Move on to the next line.
Loop
stream_reader.Close()
' We'll assume you have all the filepaths in a listbox
' it would work the same for any other collection type
pCount = ListBox1.Items.Count
ReDim p(pCount - 1)
For i = 0 To pCount - 1
p(i) = New Process With {.EnableRaisingEvents = True}
AddHandler p(i).Exited, AddressOf ProcessExit
p(i).StartInfo.FileName = ListBox1.Items(i).ToString
p(i).Start()
Next
End Sub
Private Sub ProcessExit(ByVal sender As Object, ByVal e As System.EventArgs)
pCount -= 1
If pCount = 0 Then
MsgBox("All Done")
End If
End Sub
End Class-
with ur code...... 
No not at all, I am saying use my code and place it into your so you can pass the status of your chk boxes to your other form.
Although I feel like I mis understood your question
My Understanding:
You have a form with a list of items to install. The user selects what items he wants installed and you want to know how to get that list of checked items to your other installer form?
-
May 8th, 2013, 04:26 PM
#6
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
Hmmmm... Is there a way to read the last column in the listview?
As i have the file location in a column......
-
May 8th, 2013, 06:51 PM
#7
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
Can i do:
Code:
For Each App In SelectPrograms.App_List.Items(3).SubItems.ToString
'//Install App
Next
i'm assuming columns start at 0
-
May 9th, 2013, 09:42 AM
#8
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
-
May 9th, 2013, 09:53 AM
#9
Addicted Member
Re: Passing checked items/process to other form
You can specify which sub item it is by the name of the colum like so
vb.net Code:
ListView1.Items(3).SubItems("Name of colum")
So in that case it will return the value of the column specified of item 3.
If you are trying to get all the items in that colum you can do this
vb.net Code:
For Each item As ListViewItem In ListView1.Items item.SubItems("Name of colum").ToString() Next
EDIT: Let me double check this, I am more farmiliar with datagridview, but they seem very similar
Last edited by Crzyrio; May 9th, 2013 at 09:59 AM.
-
May 9th, 2013, 10:07 AM
#10
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
-
May 9th, 2013, 10:20 AM
#11
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
Ok i think that would work, now how would I pass checked items?
-
May 9th, 2013, 10:56 AM
#12
Addicted Member
Re: Passing checked items/process to other form
 Originally Posted by chris-2k
Ok i think that would work, now how would I pass checked items?
What exactly do you want to pass?
Your list view contains check boxes, and for every box checked you want to pass what is contained in those rows?
-
May 9th, 2013, 11:15 AM
#13
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
I need to pass listview items (checked items) to Form2 and then start the process.....
I've got (form1, pass items):
If App_List.CheckedItems.Count > 0 Then
For Each Item As ListViewItem In App_List.CheckedItems
'Need to pass checked items to the install form, but how ?
Next
Me.Hide()
InstallPrograms.Show()
Else
MessageBox.Show("Nothing selected to install!")
End If
And (form2, to start the process):
For Each App In SelectPrograms.App_List.Items(3).SubItems.ToString
Label3.Refresh()
Label5.Refresh()
Dim info As New System.Diagnostics.ProcessStartInfo
info.FileName = App
'ReadResult(1) Open the application
Dim myProcess As New System.Diagnostics.Process
myProcess.StartInfo = info
myProcess.Start() 'Start the process
myProcess.WaitForExit() 'Wait until the process started is finished
myProcess.Close() 'Release the resources
Label5.Text = "Install Complete..."
Label5.Refresh()
System.Threading.Thread.Sleep(750)
Label5.Text = ""
Label5.Refresh()
line = stream_reader.ReadLine() 'Move on to the next line.
Next
I have the file location in the last column..
-
May 9th, 2013, 02:04 PM
#14
Addicted Member
Re: Passing checked items/process to other form
Since you are just hiding the first form, you should be able to simply do this in form2
vb.net Code:
Form1.App_List.CheckedItems
-
May 9th, 2013, 03:08 PM
#15
Thread Starter
Hyperactive Member
Re: Passing checked items/process to other form
Ok i've come up with:
Code:
For Each App As ListViewItem In SelectPrograms.App_List.CheckedItems
Label3.Text = "wooork" + App.SubItems(0).Text
Label3.Refresh()
Label5.Refresh()
Dim p As New System.Diagnostics.Process
p = App.SubItems(3).Text
Dim myProcess As New System.Diagnostics.Process
myProcess.StartInfo = p
myProcess.Start() 'Start the process
myProcess.WaitForExit() 'Wait until the process started is finished
myProcess.Close() 'Release the resources
Label5.Text = "Install Complete..."
Label5.Refresh()
System.Threading.Thread.Sleep(750)
Label5.Text = ""
Label5.Refresh()
.Next
but 1 error, can ya help?
Error 1 Value of type 'String' cannot be converted to 'System.Diagnostics.Process'. H:\X17-59183\PostInstall\PostInstall\InstallPrograms.vb 25 17 PostInstall
-
May 10th, 2013, 07:43 AM
#16
Addicted Member
Re: Passing checked items/process to other form
 Originally Posted by chris-2k
Ok i've come up with:
Code:
For Each App As ListViewItem In SelectPrograms.App_List.CheckedItems
Label3.Text = "wooork" + App.SubItems(0).Text
Label3.Refresh()
Label5.Refresh()
Dim p As New System.Diagnostics.Process
p = App.SubItems(3).Text
Dim myProcess As New System.Diagnostics.Process
myProcess.StartInfo = p
myProcess.Start() 'Start the process
myProcess.WaitForExit() 'Wait until the process started is finished
myProcess.Close() 'Release the resources
Label5.Text = "Install Complete..."
Label5.Refresh()
System.Threading.Thread.Sleep(750)
Label5.Text = ""
Label5.Refresh()
.Next
but 1 error, can ya help?
Error 1 Value of type 'String' cannot be converted to 'System.Diagnostics.Process'. H:\X17-59183\PostInstall\PostInstall\InstallPrograms.vb 25 17 PostInstall
it is because of this line
vb.net Code:
Dim p As New System.Diagnostics.Process
p = App.SubItems(3).Text
You are saying that your process is = to a line of text. What are you trying to do there?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|