|
You could use the LostFocus event wich occurs as soon as the user selects another component or it looses it's focus for any other reason.
|
|
|
|
|
Look at the Validating event. It fires whenever you move the focus between controls which have CausesValidation = True .
For example, if you have a TextBox, an "OK" button and a "Cancel" button, you would set CausesValidation = True for the TextBox and "OK" button, and False for the "Cancel" button. Then, when you tab away from the TextBox to the "OK" button, or click the "OK" button, your validation code runs. When you click the "Cancel" button, it doesn't run.
|
|
|
|
|
This doesnt work the way I want it to. Whats happening.
Public Sub DoSomeWork()
'This is Pseudo-Code
ChangeImageBackColor(RED)
DoTimeConsumingWork()
ChangeImageBackColor(GREEN)
End Sub For Some reason, I never see the Image change its Color? I forget why this doesnt work.
Cheers
Ryan Baillargeon
Software Specialist
Fuel Cell Technologies Inc.
|
|
|
|
|
The good old DoEvents
<nobr>Public Sub DoSomeWork()
'This is also Pseudo-Code
ChangeImageBackColor(RED)
DoEvents
DoTimeConsumingWork()
ChangeImageBackColor(GREEN)
End Sub
or in VB.NET
<nobr>Public Sub DoSomeWork()
'This is also Pseudo-Code
ChangeImageBackColor(RED)
System.Windows.Forms.Application.DoEvents()
DoTimeConsumingWork()
ChangeImageBackColor(GREEN)
End Sub
|
|
|
|
|
Okay, I still dont get the results I want.
The DoTimeConsumingWork() function is in a DLL I programmed in C++.
I am using the ImageCOlor() as a busy indicator.
Using Doevents as you have showed me does not work the way I need it to, which is
"Show me when you start the function" - "Show me when you finish the function"
Also I should note that this is VBA code Im writing in an excel spreadsheet.
Ryan Baillargeon
Software Specialist
Fuel Cell Technologies Inc.
|
|
|
|
|
This is a cheap example for Excel VBA but even works without DoEvents. Strange...
Sub Process()<br />
Me.Cells(1, 1).Interior.Color = vbRed<br />
DoSomeWork<br />
Me.Cells(1, 1).Interior.Color = vbGreen<br />
End Sub<br />
<br />
Sub DoSomeWork()<br />
Dim s As String, n As Long<br />
For n = 0 To 13000<br />
s = s + " "<br />
Next<br />
End Sub
Got no idea then. Sorry!
|
|
|
|
|
Do Events is evil... In general I have found that it cause more race conditions than anything.
Try:
ImageObject.Refresh()
|
|
|
|
|
Does anyone have an example that shows how to get events in a VB.NET application from a click on a link on a web page?
I want to try to work on a shell application that uses aspx pages is it's interface (kind of like Outlook Today) and I need to get the clicks back into my program.
|
|
|
|
|
Use a LinkButton instead of a Hyperlink. LinkButtons raise a click event in ASPX.
|
|
|
|
|
Hi All,
I am currently need to transfer files from within a VB.Net application. I know that in VB6, you can add a control under inet. But, when I am doing it in VB.NET, I could not find anything that allow me to transfer files from within the VB .net.
If any of you know how, Please.... offer any advice!
Much appreciated!
|
|
|
|
|
i have created a simple class and want to add it to a listbox using the overloaded tostring() method...i've seen this done in about 10 examples, and straight from msdn, but it's not working for me (using a System.Web.UI.WebControls.ListBox)
even with a simple class:
-------------------
| Public Class asdf
| Public Overrides Function ToString() As String
| Return "asdf"
| End Function
| End Class
-------------------
i try to call
-------------------
| lstboxMyListBox.Items.Add(new asdf())
-------------------
or even
-------------------
| cstr(new asdf())
-------------------
and it won't let it compile because:
"Value of Type 'mynamespace.asdf' cannot be converted to 'String'"
i then tried this:
-------------------
| Public Class asdf
| Public Overloads Overrides Property ToString() As String
| Get
| Return "asdf"
| End Get
| Set(ByVal Value As String)
|
| End Set
| End Property
| End Class
-------------------
but i get an error compiling the class because:
"'ToString' conflicts with a function by the same name declared in 'Object'"
any ideas
michael griffith
--------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
|
|
|
|
|
The first approach was the right one, but you have to use
lstboxMyListBox.Items.Add(New Asdf().ToString())
Now this will work fine, but you cannot access the class anymore after that!
I think you wanted to add a set of classes to a listbox and access these classes afterwords again and let the listbox use the ToString() function to display them correct, but listbox will only accept strings. You would have to use a collection too:
Dim my_asdf As New Asdf()
colMyCollection.Add my_asdf
lstboxMyListBox.Items.Add my_asdf.ToString()
|
|
|
|
|
thanks for the reply....i actually was going about it wrong
what i'm doing now (to my disguntlement) is keeping an arraylist of my objects in the session collection, and databinding to it...it's working fine
i assumed that the ListBox.Items collection would hold objects (as long as they had a tostring() method), but i was wrong. you can, however databind to any object collection/list, as long as the tostring() method is provided, or a datavaluemember and datatextmember are specified
michael griffith
--------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
|
|
|
|
|
Can anyone explain how I can copy an Excel chart to the clipboard? It only works with text for me.
Tnx
|
|
|
|
|
Is anything equivalent in VB.Net with the WebBrowser of VB.6?
|
|
|
|
|
hi, all
The following code giving me an overflow error.
Please tell me what is wrong in code.
Private Sub Command1_Click()
Dim x As Long
Dim y As Integer
y = 10
x = 11025 * y
MsgBox x
End Sub
|
|
|
|
|
VB6 question right?
Dim x As Long
Dim y As Integer
y = 10
x = CLng(11025) * y
MsgBox x
Works fine.
But, so does this:
Dim x As Long
Dim y As Integer
y = 10
x = 11025 * CLng(y)
MsgBox x
By using 2 integers as operands, the compiler is presuming that the result will also be an integer.
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
hi,Simon thanks for your reply
but,take this code, it is working fine
with out using any type conversion
Please..
Dim x As Long
Dim y As Integer
y = 10
x = 55555 * y
MsgBox x
|
|
|
|
|
I don't have MSDN for VS6, but the upper limit for an integer is ~32,000, so in your example the "55,555" value is seen as a VB Long.
Basically, it's like this:
a. long = long * integer
b. integer = integer * integer
Your example corresponds to "a" and your initial post is like "b". The reason that "b" gave an overflow is that there's the potential for the product of 2 integers to exceed the max value for an integer (the compiler does it's best).
HTH
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
|
Ok, I have been messing around with dynamic loading of controls now all day and have a cool example that works, but I am getting some strange results on one area.
I am trying to add a way to get messages into the control that I am loading, but I digress. Here is an example of what I have:
1) I have a control that I use as a base (Called CtlBase.BaseControl) and it is defined as such:
Public MustInherit Class BaseControl
Inherits System.Windows.Forms.UserControl
Public Event MessageExit(ByVal OutputMessage As String)
Public MustOverride WriteOnly Property MessageEntry(ByVal InputMessage As String)
Protected Sub SendEvent(ByVal EventMessage As String)
RaiseEvent MessageExit(EventMessage)
End Sub
End Class
I have another project that inherits from this base control declared as such:
Public Class Ctl1
Inherits CtlBase.BaseControl
Private Sub cmdSendEvent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSendEvent.Click
SendEvent(txtSendMessage.Text)
End Sub
Public Overrides WriteOnly Property MessageEntry(ByVal InputMessage As String)
Set(ByVal Value)
txtRecvdmessage.Text = Value
End Set
End Property
End Class
Now, I have another project that is loading the Ctrl1 dynamicaly, tieing up the event that the control exsposes (that is working fine) and trying to assign data to the WriteOnly property that the control exsposes. This app looks like such:
Imports System.Reflection
Public Class Form1
Inherits System.Windows.Forms.Form
Dim c As Control
Dim m As CtlBase.BaseControl
Private Sub cmdLoad1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdLoad1.Click
Dim myObj As Object
Dim myAssem As System.Reflection.Assembly
myAssem = myAssem.LoadFrom("..\..\ControlLib\bin\ControlLib.dll")
myObj = myAssem.CreateInstance("ControlLib.Ctl1")
c = CType(myObj, CtlBase.BaseControl)
c.Dock = DockStyle.Fill
m = DirectCast(c, CtlBase.BaseControl)
AddHandler m.MessageExit, AddressOf Ctl_Click_Handler
pnlMainPanel.Controls.Add(c)
End Sub
Private Sub Ctl_Click_Handler(ByVal Message As String)
MessageBox.Show(Message & " : Was received.")
End Sub
Private Sub cmdCommand_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCommand.Click
m.MessageEntry(txtCommand.Text) = txtCommand.Text
End Sub
End Class
The very odd thing is the way that I have to do what is listed in BOLD
If I try this as:
m.MessageEntry(txtCommand.Text)
I get a -
"I:\RUS\SnapinTest\Application\Form1.vb(155): Property 'MessageEntry' is 'WriteOnly'."
If I try it as:
m.MessageEntry = txtCommand.Text
I get a -
"I:\RUS\SnapinTest\Application\Form1.vb(155): Argument not specified for parameter 'InputMessage' of 'Public MustOverride WriteOnly Property MessageEntry(InputMessage As String) As Object'."
Can ANYONE please tell me what the hell I am doing wrong?
I mean the 'm.MessageEntry(txtCommand.Text) = txtCommand.Text' code does what I want it to, but WHY? It looks very odd to me....
HELP!!!!!
|
|
|
|
|
Change the declaration of the MessageEntry property to:
Public MustOverride WriteOnly Property MessageEntry As String
Then, in Ctl :
Public Overrides WriteOnly Property MessageEntry() As String
Set(ByVal Value As String)
txtRecvdmessage.Text = Value
End Set
End Property
Then, you will be able to use:
m.MessageEntry = txtCommand.Text
Your original declaration was declaring a write-only String property which expected a single parameter of type String in addition to the value.
|
|
|
|
|
Cool...I'll give it a try when I get back to the office (attic )
Thanks...
|
|
|
|
|
Hi,
I'm trying to add a GUI effect for a form in VB.NET that will cause the window to fade to 50% transparency when the title bar is clicked on. It's easy to get the form to fade, but I'm having trouble finding a way to capture the event of clicking on the title bar. Since this is a nonclient area of the window, VB does not raise one of the built-in events for forms. If anyone knows a way for me to capture the messages for when the title bar is clicked, I would be most happy... the only way i think i can do this is by writing a control in C++ that will capture the window messages and let VB know when the title bar has been clicked... thanks in advance..
Jon
|
|
|
|
|
Try this in the form code:
Private Const WM_NCLBUTTONDOWN As Integer = &HA1
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_NCLBUTTONDOWN Then
Me.Opacity = 0.5
End If
MyBase.WndProc(m)
End Sub
|
|
|
|