|
AreJay wrote: Change the Panel Control to a Button then dynamic assign names, text and events.
You mean change the ellipse to a button ?
(note: i have many ellipses on the map..)
any help for that?
Regards
Ramy
|
|
|
|
|
hey...
plz answer me ASAP .
coz my project dead line is soon,
all what i want is to let the user click on the drwan ellipse....
thx
Regards
Ramy
|
|
|
|
|
Change the forms MouseClick Event to:
<br />
<span style="color: #0000FF">Private Sub</span> Form1_MouseClick(<span style="color: #0000FF">ByVal</span> sender <span style="color: #0000FF">As Object</span>, <span style="color: #0000FF">ByVal</span> e <span style="color: #0000FF">As System.Windows.Forms.MouseEventArgs</span>) <span style="color: #0000FF">Handles</span> <span style="color: #0000FF">Me</span>.MouseClick</p><br />
<div style="padding-left:10px; "><br />
<span style="color: #009900">' only on the left mouse button</span><br /><br />
<span style="color: #0000FF">If </span>e.Button = Windows.Forms.MouseButtons.Left <span style="color: #0000FF">Then</span><br />
<div style="padding-left:10px; "><br />
<span style="color: #009900">' new instance of random to spice up the pilot</span><br /><br />
rand = <span style="color: #0000FF">New</span> Random()<br /><br />
<span style="color: #009900">' Creating a new instance of the MapMarker Class<br /><br />
' passing a randomly generated color </span><br /><br />
mm = <span style="color: #0000FF">New</span> MapMarker(Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255)))<br /><br />
<span style="color: #009900"> ' Calling the MarkerPanel Function<br /><br />
' And passing the mouse clicks location on the form</span><br />
<span style="color: #009900"> ' Create an instance of the new panel</span><br /><br />
<span style="color: #0000FF">Dim</span> p <span style="color: #0000FF">As</span> Panel = mm.MarkerPanel(<span style="color: #0000FF">CInt</span>(e.Location.X - (mm.MyWidth / 2)), <span style="color: #0000FF">CInt</span>(e.Location.Y - (mm.MyHeight / 2)))<br /><br />
<span style="color: #009900">' Name the new panel</span><br /><br />
p.Name = <span style="color: #CC0000">"key_" </span>& markerList.Count + 1<br /><br />
<span style="color: #009900">' This is adding the control to a collection for futur reference</span><br /><br />
markerList.Add(p.Name, mm)<br /><br />
<span style="color: #009900">' Add Event Handlers to handle the on click events</span><br /><br />
<span style="color: #0000FF">AddHandler</span> p.Click, <span style="color: #0000FF">AddressOf</span> Ellipse_Click<br /><br />
<span style="color: #009900">' Adding the newly create Panel Control to the form</span><br /><br />
<span style="color: #0000FF">Me</span>.Controls.Add(p)<br />
</div><br />
<span style="color: #0000FF"> End If</span><br />
</div><br />
<span style="color: #0000FF">End Sub</span><br />
Add the following Event to the form:
<br />
<span style="color: #0000FF">Private Sub</span> Ellipse_Click(<span style="color: #0000FF">ByVal</span> sender <span style="color: #0000FF">As Object</span>, <span style="color: #0000FF">ByVal</span> e <span style="color: #0000FF">As</span> System.EventArgs)<br /><br />
<div style="padding-left:10px; ">MsgBox(CType(sender, Panel).Name)</div><br />
<span style="color: #0000FF">End Sub</span><br />
Update the MapMarker Class with:
<br />
<span style="color: #0000FF">Dim</span> p <span style="color: #0000FF">As New</span> Panel<br /><br />
<span style="color: #0000FF">With</span> p<br /><br />
<div style="padding-left:10px; "><br />
.BackgroundImage = <span style="color: #0000FF">CType</span>(m_bmp, Image)<br /><br />
.Location = <span style="color: #0000FF">New</span> Point(xCoord, yCoord)<br /><br />
.Size = <span style="color: #0000FF">New</span> Size(m_width, m_height)<br /><br />
.Cursor = Cursors.Hand <br /><br />
<span style="color: #009900">''''''''''''''''''''''''''''''<br /><br />
'.AllowDrop = True<br /><br />
' Customize the panel as needed<br /><br />
''''''''''''''''''''''''''''''</span></div><br />
<span style="color: #0000FF">End With</span><br />
I'm listening but I only speak GEEK.
|
|
|
|
|
Hi,
I am using the following code to put all of the mp3 files in the Album directories into an array. This works fine, but what if there were more subdirectories, how can I change this code so that the the computer scans every single directory and subdirectory in f:\mp3 ?
Dim strFolder As String = "f:\mp3"
For Each strArtist As String In My.Computer.FileSystem.GetDirectories(strFolder)
For Each strAlbum As String In My.Computer.FileSystem.GetDirectories(strArtist)
For Each strFile As String In My.Computer.FileSystem.GetFiles(strAlbum)
If strFile.Substring(strFile.Length - 3) = "mp3" Then
objArraylist.Add(strFile)
End If
Next
Next
Next
Sorry if this is a silly question, but I've only been working with VB.Net for 3 months!
Thanks
|
|
|
|
|
I had to do something similiar (find every directory\file path for a server) and came up with the following code. You may be able to modify it for what you need:
Dim strpath As String = "f:\mp3" 'Your starting path
Dim BaseDir As New DirectoryInfo(strpath)
Dim DirListing() As DirectoryInfo
DirListing = BaseDir.GetDirectories()
Dim tmpFI As FileInfo
Dim tmpdir As DirectoryInfo
For Each tmpdir In DirListing
For Each tmpFI In BaseDir.GetFiles()
'Preforn your check and whatnot
Next
Next
David
|
|
|
|
|
Just set the FileIO.SearchOption , like so:
My.Computer.FileSystem.GetDirectories(strAlbum, FileIO.SearchOption.SearchAllSubDirectories)
|
|
|
|
|
Excellent work.
Thanks
So easy, with such a small piece of code.
I did also have to use the next line of code to build a list of the directories, if anyone else needs to use it.
Dim dir As ObjectModel.ReadOnlyCollection(Of String)
dir = My.Computer.FileSystem.GetDirectories("f:\mp3",FileIO.SearchOption.SearchAllSubDirectories)
|
|
|
|
|
Hello,
I can view report with crystal report viewer but I want remote users be able to view and print the report using Internet explorer. In order to do that, I need to export crytal report into html programmaticaly. So that when a user click on a button, the report can be viewed in html format.
How Can I do it using vb.net?
Thank you in advance.
programmer
|
|
|
|
|
I am currently attempting to develop a dll as a control in Visual Studio 5, VB.NET. The control has been created as a class, including a form and several functions.
Now, I want to be able to call that DLL from my VB main program. I am able to identify the DLL in a known directory and load the assembly. Now I want to instantiate the assembly and be able to use properties, such as with any other control in VB.NET (i.e., a Text Box...).
I have created a stub in a module that has the same class definition as that in the DLL, but when I attempt to associate the DLL class with the stub, I get
"Unable to cast object of type 'swControl.plugin' to type 'plugin'."
I have included my source code... Anybody have any ideas. I'm obviously doing something wrong!!
MY MAIN PROGRAM...
Public Class frmMainC
Private Glist As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
Private Sub frmMainC_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'
Dim clsAssembly As System.Reflection.Assembly
Dim clsType As Type
Dim sTemp As String
'
Dim clsPlug As New plugin
'
Glist = My.Computer.FileSystem.FindInFiles(My.Application.Info.DirectoryPath & "\plugins", "dll", True, FileIO.SearchOption.SearchTopLevelOnly)
For Each name As String In Glist
Try
clsAssembly = System.Reflection.Assembly.LoadFrom(name)
For Each clsType In clsAssembly.GetTypes
If clsType.Name = "plugin" Then
clsPlug = clsAssembly.CreateInstance(clsType.FullName)
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End
End Try
'Dim var As New ucSwitch
'var.Top = Me.scMain_Console.Panel1.Top
'var.Left = Me.scMain_Console.Panel1.Left
'var.Width = Me.scMain_Console.Panel1.Width
'var.Visible = True
'var.BringToFront()
Next
End Sub
End Class
MY STUB:
Module Module1
Public Class plugin
Public Sub init()
End Sub
Public ReadOnly Property Fred()
Get
End Get
End Property
Public ReadOnly Property getsSWclass()
Get
End Get
End Property
Public ReadOnly Property PluginName()
Get
End Get
End Property
End Class
End Module
MY DLL CODE:
Public Class plugin
'Implements iPlugin
Private Sub ucSwitch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
init()
End Sub
Public Sub init()
Dim iLoop As Integer
Dim icolumns(16) As DataGridViewCheckBoxColumn
Dim Port(16) As DataGridViewCheckBoxColumn
Me.dgvSWpos.Rows.Clear()
Me.dgvSWpos.Columns.Clear()
For iLoop = 0 To 15
Port(iLoop) = New DataGridViewCheckBoxColumn
With Port(iLoop)
.HeaderText = iLoop + 1
.Name = "Ports"
End With
Me.dgvSWpos.Columns.Add(Port(iLoop))
Next
For iLoop = 0 To 3
Me.dgvSWpos.Rows.Add()
Me.dgvSWpos.Rows(iLoop).HeaderCell.Value = "Common " & Chr(iLoop + 65)
Next
Me.dgvSWpos.RowHeadersWidth = 100
End Sub
Public ReadOnly Property Fred() As String
Get
Return "Fred was here..."
End Get
End Property
Public ReadOnly Property getSWclass() As Integer
Get
Return 4
End Get
End Property
Public ReadOnly Property PluginName() As String
Get
Return "4x16 Switch"
End Get
End Property
End Class
|
|
|
|
|
Sir,
i want a code for date parsing in vb.net.Already i created a three combo boxes in design view to pick the date.backend is ms-access
Query i entered in program is
" dim date as string = combobox1.selectedvalue & "/" & combobox2.selectedvalue & "/" & combobox3.selectedvalue "
it shows error in that line .
is this right ? pls solve this query sir.
give the correct code for date declaration.
chandraprabha
pondicherry
mchandu
|
|
|
|
|
You can use the VB.NET function as follows:
Dim sDate = My.Computer.Clock.LocalTime.Date
That will format the date exactly as you are trying to get.
|
|
|
|
|
Standard question #2:
What error message do you get?
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
im trying to open a exe with vb net but i got a problem, im using the process class and the exe aplication opens as a process but i cant see the aplication.... this is the code i use
Public p As New System.Diagnostics.Process
Public si As New System.Diagnostics.ProcessStartInfo
si.FileName = "calc.exe"
si.WorkingDirectory = "C:\"
si.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized
p.StartInfo = si
p.StartInfo.Arguments = ""
p.Start()
please help me
pd: sorry for my english...
Luis
|
|
|
|
|
The code looks right, but will NOT work in an ASP.NET page. VB.NET code runs server-side and will launch this calculator on the server, NOT the client side. The calculator will also NOT show on the servers desktop because it's being launched from a Service.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I used to be able to set DirectoryInfo to a path greater than 256 characters in VS2003 by using the GetShortPathName functuon but since I updated my code in VS2005 DirectoryInfo sees the path as the full length not the short path. It throws a PathTooLongException.
Does anyone know how I can get around this?
Example:
'ReallyLongPath is over 300 charactes long.
Dim ReallyLongPath as string = "D:\LongFolder\LogSubFolder\etc..."
Dim di As DirectoryInfo = New DirectoryInfo(GetShortPathName(ReallyLongPath))
|
|
|
|
|
That trick isn't going to work. One of the first things the constructor for the DirectoryInfo object does, in .NET 2.0, is convert the path you give it to a normalized form. That means converting it to it's Full Path specification. The limit on that returned (internally used) path is 260 characters.
No matter what, it's NEVER a good idea to use paths that long, for any reason. Not because of compatibility issues with the .NET Framework, but because of the same issues with other software, like BackupExec. Keep your paths under 260 characters if you want to avoid future problems.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I understand the reasons for keeping the paths to a decent lenth but I currently have a machine that has paths that go much deeper than 260 characters and the shortpath trick used to work fine with the drirectoryinfo object in .Net 1.x. Is there no way around this in .Net 2.0?
Thanks.
|
|
|
|
|
Nope. Like I said, the first thing the DirectoryInfo object does is normalize the path to its full length, so you can't use it for what you're doing.
You can try to use the the static methods (Directory class, not DirectoryInfo) and try to use the return path from GetShortPathName as the directory to search. But, I'm seeing code in there that looks like it might also normalize the path too, though it might not.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
Hi everybody,
I am creating a small website, in which i want to use windows media player's video file. I am providing a navigation button to go through the website. But i want to keep disable that button untill the video is finished. Once the video is completed then button shuold be enable.
If any one can help me for this problem, please do my favour.
Thank you.
Best Regards,
Ahmad Tasnim Siddiqui
Mail id: tasnim5@yahoo.com
Tasnim
|
|
|
|
|
You'll have to ask this in the ASP.NET or Web Development Forums. THis will require client-side JavaScript. You can't do it using VB.NET on the server-side.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave,
Thank you for your valuable suggession.
Take Care,
Regards,
Ahmad
|
|
|
|
|
hi,
i have added a button in windows datagrid. it works fine when i load the grid first time and click the button. but if i reload the datagrid again on some event and i click the button, its click handler is called twice.
if i again load the grid then the click handler is called thrice.
how can i correct this ?
i want to call the button's click handler only once like in normal application.
Regards,
Kapil Thakur
(Where's there is Kapil , there is a way) - thakur.kapil@gmail.com
|
|
|
|
|
Somewhere in your code you used AddHandler to wire up the Click events of the button. Before you reload the data into the grid, use RemoveHandler to unwire those buttons before you destroy them.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
or you can use module level boolean variable to check wether the button is already clicked
|
|
|
|