473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

program shut down when looping datagrid..

Hi
I have a datagrid that have checkboxes added to it and there is also a
button that I want to use as a check what rows has been selected in
the datagrid. But when I use this piece if code the program just
close when I press the button that is supposed to show the selected
rows in the datagrid

<code>

Public Function GetSelectedRows(ByVal dg As DataGrid) As
System.Collections.ArrayList

Dim al As New ArrayList
Dim cm As CurrencyManager = Me.BindingContext(dg.DataSource,
dg.DataMember)
Dim dv As DataView = CType(cm.List, DataView)
Dim i As Integer
For i = 0 To dv.Count - 1
If dg.IsSelected(i) Then
al.Add(i)
End If
End
Next
Return al
End Function 'GetSelectedRows

Private Sub btnMakePDF_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnMakePDF.Click
Dim s As String = "Selected rows:"
Dim o As Object
For Each o In GetSelectedRows(MyDataGrid)
s += " " + o.ToString()
Next o
MessageBox.Show(s)
'MessageBox.Show("Selected items....")
End Sub 'button1_Click

</code>
Does anyone know why?
Regards
Magnus
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #1
5 1413
"magmo" <ma****@rad-o-resultat-dot-se.no-spam.invalid> schrieb
I have a datagrid that have checkboxes added to it and there is also
a button that I want to use as a check what rows has been selected
in the datagrid. But when I use this piece if code the program
just close when I press the button that is supposed to show the
selected rows in the datagrid

<code>

Public Function GetSelectedRows(ByVal dg As DataGrid) As
System.Collections.ArrayList

Dim al As New ArrayList
Dim cm As CurrencyManager =
Me.BindingContext(dg.DataSource,
dg.DataMember)
Dim dv As DataView = CType(cm.List, DataView)
Dim i As Integer
For i = 0 To dv.Count - 1
If dg.IsSelected(i) Then
al.Add(i)
End If
End
Next
Return al
End Function 'GetSelectedRows


Maybe I misunderstood, but executing "End" is not there to keep the
application alive...
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Your Command "End" should be "End Function" or so...

/Lars

"magmo" <ma****@rad-o-resultat-dot-se.no-spam.invalid> skrev i meddelandet
news:40********@Usenet.com...
Hi
I have a datagrid that have checkboxes added to it and there is also a
button that I want to use as a check what rows has been selected in
the datagrid. But when I use this piece if code the program just
close when I press the button that is supposed to show the selected
rows in the datagrid

<code>

Public Function GetSelectedRows(ByVal dg As DataGrid) As
System.Collections.ArrayList

Dim al As New ArrayList
Dim cm As CurrencyManager = Me.BindingContext(dg.DataSource,
dg.DataMember)
Dim dv As DataView = CType(cm.List, DataView)
Dim i As Integer
For i = 0 To dv.Count - 1
If dg.IsSelected(i) Then
al.Add(i)
End If
End
Next
Return al
End Function 'GetSelectedRows

Private Sub btnMakePDF_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnMakePDF.Click
Dim s As String = "Selected rows:"
Dim o As Object
For Each o In GetSelectedRows(MyDataGrid)
s += " " + o.ToString()
Next o
MessageBox.Show(s)
'MessageBox.Show("Selected items....")
End Sub 'button1_Click

</code>
Does anyone know why?
Regards
Magnus
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 20 '05 #3
* ma****@rad-o-resultat-dot-se.no-spam.invalid (magmo) scripsit:
I have a datagrid that have checkboxes added to it and there is also a
button that I want to use as a check what rows has been selected in
the datagrid. But when I use this piece if code the program just
close when I press the button that is supposed to show the selected
For i = 0 To dv.Count - 1
If dg.IsSelected(i) Then
al.Add(i)
End If
End

^^^

This will exit the app.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Ahh, ok that explain a lot.

When I run the check, the check doesnt indicate that any rows are
selected even though I have selected rows in the datagrid. Does
anyone see what might be wrong?

Regards
Magnus
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #5
Hi,

Your code looks to see if the whole row is selected. Shouldn't you be
checking to see if the checkbox is checked?

Ken
-----------------

"magmo" <ma****@rad-o-resultat-dot-se.no-spam.invalid> wrote in message
news:40**********@Usenet.com:
Ahh, ok that explain a lot.

When I run the check, the check doesnt indicate that any rows are
selected even though I have selected rows in the datagrid. Does
anyone see what might be wrong?

Regards
Magnus
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
HYPERLINK "http://www.usenet.com"http://www.usenet.com


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.1.2 - Release Date: 6/7/2004
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2153
by: Brian Roberts | last post by:
I have a command line Python program that sometimes takes a bit (several minutes) to run. I want to provide an optional method for an impatient user (me!) to check the status of the program. The...
1
1319
by: Phoenix | last post by:
Is there any way to disable being able to shut down a program totally? I would have to allow it to be closed when the computer is shutting down or the user is logging out, but other than that it...
4
1485
by: John | last post by:
I was running a simple calculator program in visualbasic.net 2002 with a windows applications on XP Home, when this message popup as a Microsoft Development Environment box and said following:...
2
11388
by: Brian Worth | last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0 was able to shut down or restart the (windows XP) machine using a series of API calls. (Getlasterror, GetCurrentProcess,...
5
11088
by: scorpion53061 | last post by:
Is there a way that anyone knows to force a vb.net program to shut down and then restart itself?
0
2021
by: ArkJ | last post by:
Hello. I have a little problem. I created a little Service which uses SIP, all works rather well, but when I want to shut it down in the Services panel, it looks as if it's shut down, but in fact...
10
28746
by: Zytan | last post by:
Threads are not auto-terminated when the main form closes (not that they should be). What's the best way to terminate them when the program exits? Catch the on close message of the form, and give...
6
10532
sashi
by: sashi | last post by:
Shut down Windows For various reasons you may require a shut down of Windows to happen programmatically. For instance if the installation of your program requires system reconfiguration. The...
7
1629
by: cmdolcet69 | last post by:
Does anyone know how i could save a user textbox entery value and then when the program is shut down it would save that value for the next time so that it appears when the user start the program...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.