|
Sure. ALl you have to do is append the names of your ComboBoxes to the Handles clause of the method header:
Private Sub methodName(blah, blah) Handles ComboBox1.eventName, ComboBox2.eventName, ComboBox3.eventName, ...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm sorry but...?
Why display a list of options, and then not allow the selection of any?
Roy.
|
|
|
|
|
The control switches back and forth between
ReadOnly and not ReadOnly depending on who
is logged on.
Some users will have the right to make the
change, others won't. All should at least
see what the options are.
|
|
|
|
|
You could inherit a control from the combo box and add your behavior to it...
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
|
I am currently looking into using the PropertyGrid Control for the first time, but am having problems with when it calls the Get and Set methods of the property. Basically, I want to write a wrapper around a set of properties that are defined in some precompiled code to allow the propertygrid to use them. Basically, I am trying to have the propertygrid directly read and write the configuration values in this class.
The problem comes in when I try to create an expandable property. The expansion works fine, but due to the way I wrote the code, the 'set' method never gets run when one of the fields in the expanded view is modified. The set method does run, however, when I edit the field directly (without expanding it).
Now it would seem that this is a limitation of using custom expanded forms, however I also noticed that using the built in System.Drawing.Point class does not have this problem. When using the property grid with this class, expanding the property and editing an expanded form causes the set method of the property to be called immediately.
I am trying to explain this as best I can, but it is rather odd and complex to explain so feel free to ask questions.
The basic buggy behavior in the code below is that when trying to change a field in the expanded 'AngleRange' set of values, the Set method for this property does not get called, so the underlying values (_MILGeometricFinder.Models.Item(_ModelNum).Angle.Value, .NegativeDelta, .PositiveDelta) do not get changed.
On the otherhand in the ModelOrigin Property, any time you change the values of the expanded fields, the set gets called immediately and updates the proper values. As far as I can tell, this must have to do with the way that the System.Drawing.Point class is declared. It seems to have a way of informing the propertygrid control that a set has been called on one of its properties, so the propertygrid should call a set on that particular property.
Here is my code:
Main form code to link the propertygrid in:
PropertyGrid1.SelectedObject = New ModelFinderProperties(_MILGeometricFinder)
Excerpt From the PropertyList that the Propertygrid Reads:
Imports System.ComponentModel
Imports Matrox.ActiveMIL
'''
<DefaultPropertyAttribute("Title")> _
Public Class ModelFinderProperties
'''
Private _MILGeometricFinder As AxMatrox.ActiveMIL.ModelFinder.AxMModelFinder = Nothing
Private _ModelNum As Integer = 1
Public Sub New(ByRef ModelFinder As AxMatrox.ActiveMIL.ModelFinder.AxMModelFinder, Optional ByVal ModelNum As Integer = 1)
_MILGeometricFinder = ModelFinder
_ModelNum = ModelNum
End Sub
<CategoryAttribute("Training Parameters"), _
Browsable(True), _
[ReadOnly](False), _
BindableAttribute(False), _
DefaultValueAttribute("(0.0,0.0)"), _
DesignOnly(False), _
DescriptionAttribute("The (0,0) Point of a found model.")> _
Public Property ModelOrigin() As Point
Get
Return New Point(_MILGeometricFinder.Models.Item(_ModelNum).ReferenceX(), _
_MILGeometricFinder.Models.Item(_ModelNum).ReferenceY())
End Get
Set(ByVal Value As Point)
_MILGeometricFinder.Models.Item(_ModelNum).ReferenceX = Value.X
_MILGeometricFinder.Models.Item(_ModelNum).ReferenceY = Value.Y
End Set
End Property
'''
<CategoryAttribute("Search Parameters"), _
Browsable(True), _
[ReadOnly](False), _
BindableAttribute(False), _
DefaultValueAttribute("(0.0,0.0)"), _
DesignOnly(False), _
DescriptionAttribute("The starting and offset angle ranges to use when searching.")> _
Public Property AngleRange() As RangeCls
Get
With _MILGeometricFinder.Models.Item(_ModelNum).Angle
Return New RangeCls(.Value, .NegativeDelta, .PositiveDelta)
End With
End Get
Set(ByVal newValue As RangeCls)
With _MILGeometricFinder.Models.Item(_ModelNum).Angle
.Value = newValue.Reference
.NegativeDelta = newValue.NegativeDelta
.PositiveDelta = newValue.PositiveDelta
End With
End Set
End Property
End Class
My RangeCls:
Imports System.ComponentModel
<TypeConverter(GetType(RangeClsConverter))> _
Public Class RangeCls
'''
Private _Reference As Double
Private _NegativeDelta As Double
Private _PositiveDelta As Double
'''
Public Sub New(ByVal Reference As Double, ByRef NegativeDelta As Double, ByRef PositiveDelta As Double)
_Reference = Reference
_NegativeDelta = NegativeDelta
_PositiveDelta = PositiveDelta
End Sub
'''
Public Sub New()
Me.new(0, 0, 0)
End Sub
<DescriptionAttribute("Set the reference value.")> _
Public Property Reference() As Double
Get
Return _Reference
End Get
Set(ByVal Value As Double)
_Reference = Value
End Set
End Property
'''
<DescriptionAttribute("Set the positive delta.")> _
Public Property PositiveDelta() As Double
Get
Return _PositiveDelta
End Get
Set(ByVal Value As Double)
_PositiveDelta = Value
End Set
End Property
'''
<DescriptionAttribute("Set the negative delta.")> _
Public Property NegativeDelta() As Double
Get
Return _NegativeDelta
End Get
Set(ByVal Value As Double)
_NegativeDelta = Value
End Set
End Property
End Class
Friend Class RangeClsConverter : Inherits ExpandableObjectConverter
Public Overloads Overrides Function _
CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, _
ByVal destinationType As System.Type) As Boolean
If (destinationType Is GetType(RangeCls)) Then
Return True
End If
Return MyBase.CanConvertTo(context, destinationType)
End Function
Public Overloads Overrides Function _
CanConvertFrom(ByVal context As System.ComponentModel.ITypeDescriptorContext, _
ByVal sourceType As System.Type) As Boolean
If (sourceType Is GetType(String)) Then
Return True
End If
Return MyBase.CanConvertFrom(context, sourceType)
End Function
Public Overloads Overrides Function _
ConvertFrom(ByVal context As System.ComponentModel.ITypeDescriptorContext, _
ByVal culture As System.Globalization.CultureInfo, _
ByVal value As Object) As Object
If TypeOf value Is String Then
Try
Dim s As String = CType(value, String)
Dim rangeParts(3) As String
Dim _RangeCls As RangeCls = New RangeCls
Dim delimiterIndex As Integer
delimiterIndex = InStr(s, "[")
rangeParts(0) = Left(s, delimiterIndex - 1)
s = Mid(s, delimiterIndex + 1)
delimiterIndex = InStr(s, ",")
rangeParts(1) = Left(s, delimiterIndex - 1)
s = Mid(s, delimiterIndex + 1)
delimiterIndex = InStr(s, "]")
rangeParts(2) = Left(s, delimiterIndex - 1)
_RangeCls.Reference = Convert.ToDouble(rangeParts(0))
_RangeCls.NegativeDelta = Convert.ToDouble(rangeParts(1))
_RangeCls.PositiveDelta = Convert.ToDouble(rangeParts(2))
Return _RangeCls
Catch ex As Exception
Throw New ArgumentException("Can not convert '" + _
value + "' to type RangeCls")
End Try
End If
Return MyBase.ConvertFrom(context, culture, value)
End Function
Public Overloads Overrides Function _
ConvertTo(ByVal context As _
System.ComponentModel.ITypeDescriptorContext, _
ByVal culture As System.Globalization.CultureInfo, _
ByVal value As Object, ByVal _
destinationType As System.Type) As Object
If (destinationType Is GetType(System.String) AndAlso _
TypeOf value Is RangeCls) Then
Dim _RangeCls As RangeCls = CType(value, RangeCls)
Return _RangeCls.Reference & " [" & _RangeCls.NegativeDelta & _
", " & _RangeCls.PositiveDelta & "]"
End If
Return MyBase.ConvertTo(context, culture, value, destinationType)
End Function
End Class
|
|
|
|
|
Hi,
this is because the PointConverter overrides GetCreateInstanceSupported (returns true) and CreateInstance (which returns a new Point when sub properties are modified). You should do the same in your own converter. Hope this helps.
|
|
|
|
|
I need to know how to parse an XML file with different node names.
jds
|
|
|
|
|
With XPath and the DOM ( XMLDocument class ), probably.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I've created a web service with an .asmx file that contains many <WebMethod()> functions that I can consume in other projects just fine. Is it possible to somehow share classes belonging to the web service that are not inside the .asmx file?
On the consuming end I would like to be able to declare and use the classes belonging to the web service e.g.
Dim Bleh as new ReferenceName.service.SomeClassBelongingToTheWebService
Bleh.ExecuteSomeFunction()
Bleh.SetSomeProperties = "SomeString"
Is this possible? I currently don't have access to any of the classes belonging to the web service and I have to place all functions inside of the service.asmx file. If I could access the classes belonging to the web service then I could use it to pass strong typed collections and keep my functions grouped accordingly. Thanks so much!
- Paul Anderson
|
|
|
|
|
Yes, that should be possible. It is when I create one.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Can you supply me with the code you created because I’m having trouble exposing the classes in my web service. Thank you so much.
- Paul Anderson
|
|
|
|
|
I've reciently used a web service and needed to refernce the web service's dll inside the new application's project. This allowed me to:
Imports MyNamespace.com.webservices<br />
Dim _webdata As WebServices<br />
_webdata = new WebServices()
But you'll need to Add Web Reference to the project.
|
|
|
|
|
It worked! Thanks so much for your help!
|
|
|
|
|
Hi,
This is very urgent. We are to deliver at month end at are struck at a point where, we ahve a weighing machine connected to my computer through a com port (COM1). Now, we are developing an application in vb 6.0 to read the weight that is placed on the weighing machine.
The problem is, the application is not fetching the value from the COM PORT and when it is fetching it is a junk data.
Can anyone give an idea where to find help or provide with any link or provide with any code?
Any help would be awesome...
Anirban Deb.
|
|
|
|
|
You should check the comm event, something like the following:
mscomm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive ' Received RThreshold # of chars.
g_rcvd = g_rcvd & MSComm1.Input
End Select
end sub
Depending on what your scale is doing you may need to add some code to check for pauses in the code (like check to see how long it has been since g_rcvd has changed)
Regarding the "junk data" I am suspecting is is returning ASCII, of HEX binary data and you will need to translate it (Bin 2 hex, use Chr$ function or something like that), not all hex values have good ASCII charactors to represent them, so it looks like junk....
good luck...
A signature is only a signature if it is signed,
signed
|
|
|
|
|
Hi all.
I'm Alessio and I've still some problems with remoting.
I've got a server app and a client app.
The server app expose an obj by .net remoting and the client creates a reference to it.
From the client I can call all the remoting obj methods and all works fine (and I'm very happy).
BUT (there's always a "but"), one of these methods requires two parameters:
- a string
- a XmlDocument byref
I can't call this method because the XmlDocument I want to pass from client to server, isn't serialized.
So, how can I serialize it ?
I hope there will be someone who can help me, because if not, probably, next week, I will be a dead-man.
Thanx in advance
Alessio
|
|
|
|
|
This is the code to serialize an object (that is serializable)
Public Function sSerializeObject(ByVal oObject As Object) As String
Dim oSerializer As New XmlSerializer(oObject.GetType)
Dim oSR As New MemoryStream, bt() As Byte
Try
oSerializer.Serialize(oSR, oObject)
bt = oSR.GetBuffer
sSerializeObject= System.Text.Encoding.ASCII.GetString(bt)
oSR.Close()
oSR = Nothing
oSerializer = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
|
|
|
|
|
Ok, but you say "This is the code to serialize an object (that is serializable)".
My object is a XmlDocument, and it doesn't implements the serializable interface.
So, is the better way pass as byref parameter a string (or a stream) and then parse it with "loadXml" method ?
|
|
|
|
|
If your using .net remoting like I know it, then BYREF is questionable. I don't think that's possible -- you may know more about that...
You can convert the xmldocument a string, pass it over to your server pc via tcp connection(stream) and then do a loadxml on the server and process it, then pass back the changes and then replace your document with the one the server returned...
|
|
|
|
|
I want to develop a software directory like the one you see in Snapfiles
I am just confused how i should design the database for that.
It has 2 levels of hierarchy. The first level there is Browser Tool, Communication,...
The second level is Bookmark Manager, Chat(IRC),Font Tools
(^^^ these r from the site)
I think i have create 3 tables for that. One for the first level, 2nd for the second level & the 3rd for the software listings.
I am going to use VB.net for front end. Not sure if i should access or sql server as the back end.
I just want the opinion as i am newbie & inexperienced.
If i am asking in the wrong place, pls guide me to the right place or atleats tell me how i can find the right place
|
|
|
|
|
Can anyone tell me if vb2005 has a function comparable to InvokeVerbEx("Print")?
I have a folder that contains a number of .pdf files. I would like to have my code print each one of the .pdf files. If I right click on the file and click 'print', acrobat opens, prints the file, and then closes the file. Acrobat stays open, which is fine. I just want to send the files to the printer.
Thanks in advance.
|
|
|
|
|
Search for hours....no success.
Post a question...find it in 10 minutes. Go figure.
Here is what I found in case anyone cares.
Dim p As New System.Diagnostics.ProcessStartInfo()
p.Verb = "print"
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\filename.htm"
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)
|
|
|
|
|
Hello, i have recently developed an application using the Windows Media Player ActiveX/SDK
I want to be able to load plugins available in Windows Media Player in my application, such as the Windows Live/MSN Messenger Status plugin, so when somebody listens to a music track in my application it would trigger the plugin to activate and work like it was in WMP.
I'm sure there is a simple procedure, but maybe i am overlooking it...
Please help
Thanks
|
|
|
|
|
I have two functions created, one that creates a zip folder which contains files and one that creates a backup folder. I need to know how to copy that zip folder to the backup folder.
Thanks!
jds1207
|
|
|
|
|
JDS,
Dim oDir As DirectoryInfo,sZipPath as string,sBackupPath As String
sZipPath="c:\zip\"
sBackuppath="C:\backup\"
oDir = New DirectoryInfo(sZipPath)
For Each oFile As FileInfo In oDir.GetFiles
File.Copy(oFile.FullName, sBackuppath & oFile.Name, True)
Next
'copies all files from the zip directory to the backup directory and replaces if alread there...
Hope this helps
nathan
|
|
|
|
|