473,624 Members | 2,278 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.Collecti ons.ArrayList

Dim al As New ArrayList
Dim cm As CurrencyManager = Me.BindingConte xt(dg.DataSourc e,
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 'GetSelectedRow s

Private Sub btnMakePDF_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnMakePDF.Clic k
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.Sho w("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 1422
"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.Collecti ons.ArrayList

Dim al As New ArrayList
Dim cm As CurrencyManager =
Me.BindingConte xt(dg.DataSourc e,
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 'GetSelectedRow s


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.Collecti ons.ArrayList

Dim al As New ArrayList
Dim cm As CurrencyManager = Me.BindingConte xt(dg.DataSourc e,
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 'GetSelectedRow s

Private Sub btnMakePDF_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnMakePDF.Clic k
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.Sho w("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
2159
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 type and amount of status information doesn't fit nicely into a --verbose or logger -- either too little or too much information at different points. I think an optional web page would be convenient interface. The Python program would listen...
1
1332
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 can't shut down no matter what. Can anybody give me any suggestions? I'd like to use c# but moreover I just need some direction in where to go with this.. Somebody had suggested to me to make a service that monitors the app running as a user on a...
4
1495
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: Attaching the .NET debugger to process' Take-home pay calculator.exe' on machine 'name of my machine' failed. Error code 0x80004002. If anyway could direct me in solving this problem, it would help me very much. Thank you
2
11399
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, OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivilegese, ExitWindowsEx. I am trying to avoid using any API calls if possible and to use managed code instead. I couldn't find any easy way of doing this but searching the Internet with...
5
11101
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
2038
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 it's not: - when I try want to delete the .DLL file, I can't: the file is still locked - if I "Start" my Service again, it refuses I have to wait like ~20s, and then it is really shut down. When I shut down the Service, and then try to Start it...
10
28757
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 a signal to the threads that they must shut down? Seems I need a destructor for that. Forms don't have an overridable Dispose method. So, how can I react when the form closes? Note my example thread just (abnormally) runs forever until it is...
6
10539
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 following code will do this for you with options to Reboot, etc. 'Module code - modShutdown ' Shutdown Flags Const EWX_LOGOFF = 0 Const EWX_SHUTDOWN = 1
7
1634
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 back up Example: user enters his name:Chuck I want to be able to save the entery (chuck) so that when he exits the program (shut down) and then start it back up again the user entry
0
8242
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8488
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
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 we have to send another system
1
1793
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.