Hi - I am using custom textboxes and I need to be able to set the Text on txb1 based on the Text of txb2. I have simplied my code to the following: -
Public Class customtextbox
-
Inherits TextBox
-
Public Event ControlReset()
-
Public Sub New(ByVal strP As String)
-
MyBase.New()
-
AddHandler customtextbox.ControlReset, AddressOf Me.test
-
End Sub
-
Public Sub test()
-
Me.Text = "chips" + Me.Name
-
End Sub
-
Public Sub ProcessAlert()
-
RaiseEvent ControlReset()
-
End Sub
-
Private Sub customtextbox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
-
Dim cT As Control
-
Dim cS As customtextbox
-
If Me.Name = "txb1" Then
-
If Me.Text = "fried" Then
-
For Each cT In frmTest.Controls
-
If cT.Name = "txb2" Then
-
cS = cT
-
Call cS.ProcessAlert()
-
End If
-
Next
-
End If
-
End If
-
End Sub
-
End Class
-
and the form code is: - Public Class frmTest
-
Public Sub New()
-
InitializeComponent()
-
Dim txb1 As customtextbox
-
Dim txb2 As customtextbox
-
txb1 = New customtextbox("params for txb1")
-
txb1.Name = "txb1"
-
txb1.Location = New Point(10, 10)
-
txb1.Size = New Point(200, 20)
-
Me.Controls.Add(txb1)
-
txb2 = New customtextbox("params for txb2")
-
txb2.Name = "txb2"
-
txb2.Location = New Point(10, 30)
-
txb2.Size = New Point(200, 20)
-
Me.Controls.Add(txb2)
-
End Sub
-
End Class
-
So, when txb1 looses focus, if its Text is "fried", then it sets off txb2's ProcessAlert function. I had tried to change the value of txb2 Text in ProcessAlert function, but didnt work, so I tried to get it to raise an event instead, which then tries to set the Text property. However I still cant set txb2's Text property. The Text property seems to be set for the duration of the "life" of the Event handler. When I step through the forms controls within the Event handler, the changed Text value is there, but not outside of the Event handler.
Any suggestions???
Many thanks
2 1386
I'm a C# guy, not a VB guy, so someone correct me if I am wrong here... - Dim cS As customtextbox
-
If Me.Name = "txb1" Then
-
If Me.Text = "fried" Then
-
For Each cT In frmTest.Controls
-
If cT.Name = "txb2" Then
-
cS = cT
-
Call cS.ProcessAlert()
-
The event is being fired in the newly created cS textbox not in located cT textbox. I suspect there is no reason for the cS control at all and could be simplified as - If Me.Name = "txb1" Then
-
If Me.Text = "fried" Then
-
For Each cT In frmTest.Controls
-
If cT.Name = "txb2" Then
-
Call cT.ProcessAlert()
Of course since this is a custom control we have no idea what .ProcessAlert() does, so if the problem resides there....
Thanks for the reply. I had to use the cS as the ProcessAlert() is a sub within the custom control, and thus not available from a standard control type. The ProcessAlert just raised an event on another custom control that changes its text.
I have changed my coding and taken most of the subs out of the custom control and put them in the form that creates them (there was a lot more code, this was just a simple example I created to try and solve the problem), and also passed the form to the custom controls, so the custom controls have direct access to the subs. Now that I am calling the subs from the form rather than the custom controls, it seems to work OK.
Cheers
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Marina |
last post by:
Here is the problem. If 2 different properties on the same (or different)
control are bound to the same data column, changing the Text property and
calling EndCurrentEdit discards the new value. ...
|
by: Lucas, Todd |
last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing
for a Menu. I've been at it for about 3 weeks now, and can't seem to get
around this problem. So I'm hoping that someone...
|
by: Chris Ericoli |
last post by:
Hi,
I am working with an 'in session' ado dataset with an asp.net application.
My dataset is comprised of two tables, one of which maintains a few
calculated datacolumns. For some reason these...
|
by: qwerty |
last post by:
I´m new to ASP.Net. My workmate has some experience with it.
He claimed that in ASP.Net working with frames is much simpler than it
was ASP. I asked explanation but he couldn't give me such. (a...
|
by: Chris Fink |
last post by:
Does anyone know it is possible to include a small image(.gif .jpeg)
within a <SELECT><option> so that the user would see the option text as
well as a little image(icon) in the option? I know this...
|
by: osmarjunior |
last post by:
Hello there...
I have a custom user control, in which i put a panel on the top.
In the Paint event of the panel, i have the following code:
VisualStyleRenderer x = new...
|
by: c676228 |
last post by:
Hi everyone,
I have a piece of code in sales.aspx.vb like this:
Protected WithEvents Message As System.Web.UI.WebControls.Label
Try
...
ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr +...
|
by: Ron M. Newman |
last post by:
Hi,
I can load an assembly using the Assembly.Load(....)
However, I'd like dynamic loading of assemblies to be identical to putting
an assembly reference in your VS2005 project. and yes, I...
|
by: Brad Baker |
last post by:
I am trying to make a "tabbed" interface by iterating through a dataset with
a conditional statement. For example:
...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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: 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...
| |