473,409 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Handles Mix

Ok, so I've got a weird question. I'm working with an outside class
that someone made that will save the application settings in the
Application Data Folder. However, one problem I'm having, and I
already found the (lengthy) fix for is that I'm not able to mix
handles:

Private Sub uicheck1_CheckedChanged _
(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
uicheck1.CheckedChanged, _
uicheck2.CheckedChanged, _
uicheck3.CheckedChanged, _
uitext1.TextChanged

What happens when I run my code like that, it won't run the portion to
save whatever check boxes are checked, however; it saves the changed
text in my textbox just fine. Is there something that I'm missing
here, because when I remove the uitext1.textchanged, it works
perfectly fine. The problem with that is that I'm kind of wanting to
cut down on the code on this part of the app since it's a bit silly to
copy and paste my saving and loading code several times.

Aug 31 '07 #1
4 1217
lmefford,

The one handler can handle the checkbox checkedchanged and textbox
textchanged for any number of checkbox and textbox controls. So that is not
the problem.

Perhaps the code in the handler is the problem.

Kerry Moorman
"lm******@gmail.com" wrote:
Ok, so I've got a weird question. I'm working with an outside class
that someone made that will save the application settings in the
Application Data Folder. However, one problem I'm having, and I
already found the (lengthy) fix for is that I'm not able to mix
handles:

Private Sub uicheck1_CheckedChanged _
(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
uicheck1.CheckedChanged, _
uicheck2.CheckedChanged, _
uicheck3.CheckedChanged, _
uitext1.TextChanged

What happens when I run my code like that, it won't run the portion to
save whatever check boxes are checked, however; it saves the changed
text in my textbox just fine. Is there something that I'm missing
here, because when I remove the uitext1.textchanged, it works
perfectly fine. The problem with that is that I'm kind of wanting to
cut down on the code on this part of the app since it's a bit silly to
copy and paste my saving and loading code several times.

Aug 31 '07 #2
Create either two handlers, one for each class (checkboxes, textboxes), or
create four, one for each object. Each handler can then call a common
subroutine where the handler you wanted resides.
>
Aug 31 '07 #3
On Aug 31, 4:16 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
lmefford,

The one handler can handle the checkbox checkedchanged and textbox
textchanged for any number of checkbox and textbox controls. So that is not
the problem.

Perhaps the code in the handler is the problem.

Kerry Moorman

"lmeff...@gmail.com" wrote:
Ok, so I've got a weird question. I'm working with an outside class
that someone made that will save the application settings in the
Application Data Folder. However, one problem I'm having, and I
already found the (lengthy) fix for is that I'm not able to mix
handles:
Private Sub uicheck1_CheckedChanged _
(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
uicheck1.CheckedChanged, _
uicheck2.CheckedChanged, _
uicheck3.CheckedChanged, _
uitext1.TextChanged
What happens when I run my code like that, it won't run the portion to
save whatever check boxes are checked, however; it saves the changed
text in my textbox just fine. Is there something that I'm missing
here, because when I remove the uitext1.textchanged, it works
perfectly fine. The problem with that is that I'm kind of wanting to
cut down on the code on this part of the app since it's a bit silly to
copy and paste my saving and loading code several times.
Private Sub SaveCheckBoxes(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _
uicheck1.CheckedChanged, _
uicheck2.CheckedChanged, _
uicheck3.CheckedChanged
Dim ccontrol As Control
Dim chk As CheckBox
Dim txt As TextBox
For Each ccontrol In Me.Controls
If (TypeOf ccontrol Is CheckBox) Then
chk = DirectCast(ccontrol, CheckBox)
a.SaveSetting(chk.Name.ToString, chk.Checked.ToString)
End If
Next
End Sub

That's essentially what it is. Throw in the textbox handle and an if
statement for if the control is a textbox, and that's what it is. It
works perfectly if you seperate them and the text works fine if you
add them. I'm not sure why it does that and it doesn't make much sense
why it wouldn't work that way.

Aug 31 '07 #4
If you really want some help then posting what 'essentially what it is' cuts
no ice. You need to post 'exactly what it is'.

However, in your 'sample', do you really want information about ALL CheckBox
controls on the form saved when you change the Checked state of one Checkbox
control?

As to mixing control events to a single handler, you need to realise that
The TextBox.TextChanged event is raised every time you type a character in
the TextBox control. Given that one can write one's life story in a TextBox
control, would you really want the application settings to be saved for
EVERY individual key press?
<lm******@gmail.comwrote in message
news:11*********************@o80g2000hse.googlegro ups.com...
On Aug 31, 4:16 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
>lmefford,

The one handler can handle the checkbox checkedchanged and textbox
textchanged for any number of checkbox and textbox controls. So that is
not
the problem.

Perhaps the code in the handler is the problem.

Kerry Moorman

"lmeff...@gmail.com" wrote:
Ok, so I've got a weird question. I'm working with an outside class
that someone made that will save the application settings in the
Application Data Folder. However, one problem I'm having, and I
already found the (lengthy) fix for is that I'm not able to mix
handles:
Private Sub uicheck1_CheckedChanged _
(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
uicheck1.CheckedChanged, _
uicheck2.CheckedChanged, _
uicheck3.CheckedChanged, _
uitext1.TextChanged
What happens when I run my code like that, it won't run the portion to
save whatever check boxes are checked, however; it saves the changed
text in my textbox just fine. Is there something that I'm missing
here, because when I remove the uitext1.textchanged, it works
perfectly fine. The problem with that is that I'm kind of wanting to
cut down on the code on this part of the app since it's a bit silly to
copy and paste my saving and loading code several times.

Private Sub SaveCheckBoxes(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _
uicheck1.CheckedChanged, _
uicheck2.CheckedChanged, _
uicheck3.CheckedChanged
Dim ccontrol As Control
Dim chk As CheckBox
Dim txt As TextBox
For Each ccontrol In Me.Controls
If (TypeOf ccontrol Is CheckBox) Then
chk = DirectCast(ccontrol, CheckBox)
a.SaveSetting(chk.Name.ToString, chk.Checked.ToString)
End If
Next
End Sub

That's essentially what it is. Throw in the textbox handle and an if
statement for if the control is a textbox, and that's what it is. It
works perfectly if you seperate them and the text works fine if you
add them. I'm not sure why it does that and it doesn't make much sense
why it wouldn't work that way.
Aug 31 '07 #5

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

Similar topics

11
by: Rohit | last post by:
Hi, Threads in the .NET Framework 1.1 (and possibly in 1.0 also) leak "Event" handles, by Event handles I mean Win32 Event handles which can be monitored using the ProcessExplorer from...
1
by: Darren Wooding | last post by:
Hello, can anyone offer any advice, this one is driving me up the wall! 1. I am using a webform datagrid. 2. The columns are all dynamic and defined using templates (see code below). 3. I have...
6
by: enki | last post by:
I have been reading Ruminations on C++, a very interesting book. They are going into handles. I think what they are doing is very intersting and very confusing. I have to read each paragraph...
5
by: LBT | last post by:
I have a window service written in VB.NET to scan directory and process file. During directory scanning (scheduled by timer using System.IO.Directory.GetFiles method), I can observe that the column...
3
by: Brett | last post by:
I'm using a third part component in a certain app. The component has methods and events. I noticed one particular event was not firing after a while but it should have been. The problem was the...
12
by: johnb41 | last post by:
This question is regarding the "Handles" part of a routine, for example: Handles Button1.Click On Form2 (a User Control) I have a button. Here's it's code: Public Sub Button1_Click(ByVal...
7
by: Simon Verona | last post by:
I have a problem in my application which I believe is due to open handles.. . The symptom that users report is that after they have been using the application for a while, it will randomly just...
6
by: antonyliu2002 | last post by:
Right now I put my VB code in the aspx pages. I would prefer to use codebehind, especially many of my VB functions may be shared across multiple aspx pages. I've tried a few pages with...
2
by: sck10 | last post by:
Hello, Is there an equivalent to using "Handles" in the codebehind for c#? Or do I have to declare every event in the GridView control like the following: <asp:GridView ID="gvSearchList"...
7
by: Jurgen Haan | last post by:
Hi there. Recently, one of our application servers is moaning about its handles. (no more handles available). I'm guessing it has to do with some bug in our software where it does not release...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.