|
Hello
Could some of you, great people, please help me?
I have a array of controls and I would like to get the events.
Here is the code:
Dim pic(10) as system.windows.forms.picturebox
For a=0 to 10
pic(a)=new system.windows.forms.picturebox
' the rest of the properties
me.panel1.controls.add(pic(a))
next
How can I catch the events of the 'pic' controls?
Thanks
|
|
|
|
|
You have to write up the events of the PictureBox controls yourself using AddHandler[^].
Dim myPicBox As New PictureBox
AddHandler myPicBox.Click, AddressOf PicBoxClick
.
.
.
Private Sub PicBoxClick(ByVal sender As Object, ByVal e As System.EventArgs)
...
End Sub
Don't forget to use RemoveHandler to disconnect the handler before you destroy the picturebox.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You have used an array for the picture boxes which I don't suggest you to do that because you must have Addhandler or Eventhandler statements to control the event's of picture boxes.
According to your code, you should have one mutual eventhandler procedure which will run all the picture boxes. Focus on Addhandler and Eventhandler statements to get more information.
Here is an example from MSDN :
Sub TestEvents()
Dim Obj As New Class1
' Associate an event handler with an event.
AddHandler Obj.Ev_Event, AddressOf EventHandler
' Call the method to raise the event.
Obj.CauseSomeEvent()
' Stop handling events.
RemoveHandler Obj.Ev_Event, AddressOf EventHandler
' This event will not be handled.
Obj.CauseSomeEvent()
End Sub
Sub EventHandler()
' Handle the event.
MsgBox("EventHandler caught event.")
End Sub
Public Class Class1
' Declare an event.
Public Event Ev_Event()
Sub CauseSomeEvent()
' Raise an event.
RaiseEvent Ev_Event()
End Sub
End Class
)
|
|
|
|
|
Thanks
It worked fine!!!!
|
|
|
|
|
what is interface.
When we use interface in our program.
Continue...
|
|
|
|
|
Read this[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
when i click F1 in certain code of VB , my library help example( help1.chm) and VB help are opening. actually my library should open. closing VB help , my library help is also closing , therefore something related to parent relationship. how to hide or remove the VB help when i click F1 on related to certain help(.chm).
note: u can see visual basic for applications under references of tools menu
tools->references->VBA
its mandatory check , we cant uncheck it.
www.tamilselvan.zoomshare.com
|
|
|
|
|
tamila_tamila wrote: note: u can see visual basic for applications under references of tools menu
tools->references->VBA
its mandatory check , we cant uncheck it.
This would have nothing to do with a Help file being launched.
You're saying that VBA Help is launching along with YOUR help file? Is this code in an Office application?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
that is not the code , i do no why VB help help is alsp opening with my help. anything to be set in context sensitive help, actually i do no wat kind of help it is after clicking F1 in vb code
www.tamilselvan.zoomshare.com
|
|
|
|
|
I have built an application that watches a specified folder for any new/changes/deleted files. The program that keeps alist of all changes/added files in a listbox so that it knows what to move when instructed to. The reason this program was built to help my company transfer all changed files from our stage enviroment to our production enviroment for our website.
The entire program seems work, however when a file is copied, it seems to copy the "file.txt" but erases the data inside the original, as well as the new copy of it. Also the program checks to see if the "COPY" already exists, if so it makes a copy-of-the-copy, and puts that in a backup folder. It seems as thought when this process occurs, the data contained in that "COPY" is moved succesfully to the "BACKUP" folder, but the original "COPY" is then erased. showing "0kb". This is a big issues since I really dont' want this program deleteing all of our data when it try to move the files.
If someone can figure out why when I try to copy a file it erases the data, I would be very, very grateful.!!! I plan on posting this application working one in articles within the next few days.
Program Uses
File System Watcher
File Copy methods.
<br />
<br />
Imports System.IO<br />
Imports System.Diagnostics<br />
<br />
Public Class Form2<br />
' Created 2/7/2005 <br />
' Concept applications to watch stage for file changes, and keep record of list. Then moving all changed files to production<br />
' Copy all files that have changed, or have been created to new folder based on scheduled timeframe<br />
<br />
Public watchfolder As FileSystemWatcher<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_startwatch.Click<br />
watchfolder = New System.IO.FileSystemWatcher()<br />
<br />
'this is the path we want to monitor<br />
watchfolder.Path = txt_watchpath.Text<br />
<br />
'Add a list of Filter we want to specify<br />
'make sure you use OR for each Filter as we need to<br />
'all of those <br />
<br />
' Specifies that filesystemwatch will watch subdirectories<br />
watchfolder.IncludeSubdirectories = True<br />
<br />
watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName<br />
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _<br />
IO.NotifyFilters.FileName<br />
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or _<br />
IO.NotifyFilters.Attributes<br />
<br />
<br />
' add the handler to each event<br />
AddHandler watchfolder.Changed, AddressOf logchange<br />
AddHandler watchfolder.Created, AddressOf logchange<br />
AddHandler watchfolder.Deleted, AddressOf logchange<br />
<br />
' add the rename handler as the signature is different<br />
AddHandler watchfolder.Renamed, AddressOf logrename<br />
<br />
'Set this property to true to start watching<br />
watchfolder.EnableRaisingEvents = True<br />
<br />
btn_startwatch.Enabled = False<br />
btn_stop.Enabled = True<br />
<br />
txt_status.Text = "Watching Folder(s) & File(s)"<br />
'End of code for btn_start_click<br />
End Sub<br />
<br />
Private Sub logchange(ByVal source As Object, ByVal e As _<br />
System.IO.FileSystemEventArgs)<br />
If e.ChangeType = IO.WatcherChangeTypes.Changed Then<br />
txt_folderactivity.Text &= "File " & e.FullPath & _<br />
" has been modified" & vbCrLf<br />
<br />
' Check to see if item is already added to the list<br />
Dim a As Integer<br />
Dim CaseSense As Integer<br />
'CaseSense = 0 For CaSe SeNsItIvE<br />
'CaseSense = 1 for not case sensitive<br />
' works with List, Combo<br />
For a = 0 To changed_files.Items.Count() - 1<br />
If InStr(1, changed_files.Items(a), e.Name, CaseSense) _<br />
And Len(changed_files.Items(a)) = Len(e.Name) Then Exit Sub<br />
Next<br />
<br />
' end if exist code<br />
<br />
changed_files.Items.Add(e.Name) ' adds the modified file to the list<br />
<br />
txt_itemcount.Text = changed_files.Items.Count() ' updates the item count on-screen<br />
<br />
End If<br />
If e.ChangeType = IO.WatcherChangeTypes.Created Then<br />
txt_folderactivity.Text &= "File " & e.FullPath & _<br />
" has been created" & vbCrLf<br />
<br />
' Check to see if item is already added to the list<br />
Dim a As Integer<br />
Dim CaseSense As Integer<br />
'CaseSense = 0 For CaSe SeNsItIvE<br />
'CaseSense = 1 for not case sensitive<br />
' works with List, Combo<br />
For a = 0 To changed_files.Items.Count() - 1<br />
If InStr(1, changed_files.Items(a), e.Name, CaseSense) _<br />
And Len(changed_files.Items(a)) = Len(e.Name) Then Exit Sub<br />
Next<br />
<br />
' end if exist code<br />
<br />
<br />
changed_files.Items.Add(e.Name) ' adds the modified file to the list<br />
<br />
txt_itemcount.Text = changed_files.Items.Count() ' updates the item count on-screen<br />
<br />
End If<br />
If e.ChangeType = IO.WatcherChangeTypes.Deleted Then<br />
txt_folderactivity.Text &= "File " & e.FullPath & _<br />
" has been deleted" & vbCrLf<br />
End If<br />
End Sub<br />
<br />
Public Sub logrename(ByVal source As Object, ByVal e As _<br />
System.IO.RenamedEventArgs)<br />
txt_folderactivity.Text &= "File" & e.OldName & _<br />
" has been renamed to " & e.Name & vbCrLf<br />
End Sub<br />
<br />
Private Sub btn_stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_stop.Click<br />
watchfolder.EnableRaisingEvents = False<br />
btn_startwatch.Enabled = True<br />
btn_stop.Enabled = False<br />
txt_status.Text = "Stopped"<br />
End Sub<br />
<br />
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br />
Dim x As Integer<br />
Dim count As Integer<br />
Dim listboxitem As String<br />
count = changed_files.Items.Count() - 1<br />
<br />
If txt_watchpath.Text = "" Then<br />
Dim MsgResult As MsgBoxResult<br />
MsgResult = MsgBox("You must enter a valid (Folder to watch) path.")<br />
End If<br />
<br />
' Sets the current status of the applications (copying)<br />
txt_status.Text = "Copying Files to selected location"<br />
<br />
<br />
' Display the ProgressBar control.<br />
ProgressBar1.Visible = True<br />
' Set Minimum to 1 to represent the first file being copied.<br />
ProgressBar1.Minimum = 0<br />
' Set Maximum to the total number of files to copy.<br />
ProgressBar1.Maximum = count<br />
' Set the initial value of the ProgressBar.<br />
ProgressBar1.Value = 0<br />
' Set the Step property to a value of 1 to represent each file being copied.<br />
ProgressBar1.Step = 1<br />
<br />
<br />
<br />
<br />
For x = 0 To count<br />
<br />
changed_files.SetSelected(x, True)<br />
listboxitem = changed_files.SelectedItem.ToString()<br />
<br />
' Directories that are being manipulated.<br />
Dim path As String = txt_watchpath.Text + "\" + listboxitem ' Watch Path<br />
Dim path2 As String = txt_copyLocation.Text + "\" + listboxitem ' "Copy to" Location<br />
Dim path3 As String = txt_backupLocation.Text + "\" + listboxitem ' "Copy to (if file exists)-Backup" location<br />
<br />
Try<br />
Dim fs As FileStream = File.Create(path)<br />
fs.Close()<br />
<br />
' Ensure that the Copy locations does Not already contain the files<br />
If File.Exists(path2) Then<br />
If File.Exists(path3) Then<br />
File.Delete(path3) 'if file exists is in backup location already- delete it<br />
End If<br />
File.Copy(path2, path3) ' if copylocation file exists , move to backup folder<br />
<br />
End If<br />
File.Delete(path2)<br />
' Copy the file.<br />
File.Copy(path, path2)<br />
'Console.WriteLine("{0} copied to {1}", Path, path2)<br />
<br />
' Try to copy the same file again, which should succeed.<br />
File.Copy(path, path2, True)<br />
' Console.WriteLine("The second Copy operation succeeded, which was expected.")<br />
<br />
Catch<br />
txt_status.ForeColor.ToKnownColor.Red.ToString()<br />
txt_status.Text = "An error has occurred while copying changed/created file(s)"<br />
End Try<br />
<br />
ProgressBar1.PerformStep() ' Increment the progress bar<br />
<br />
Next x ' goes through next item in the listbox<br />
<br />
<br />
<br />
' Sets the current status of the applications (copying)<br />
txt_status.Text = "All files have been copies Succesfully!"<br />
End Sub<br />
<br />
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_brs_Folder.Click<br />
Dim folderBrowserDialog1 As New FolderBrowserDialog<br />
<br />
'Present the user with a file open dialog box.<br />
folderBrowserDialog1.ShowNewFolderButton = True<br />
If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then<br />
<br />
End If<br />
txt_watchpath.Text = folderBrowserDialog1.SelectedPath<br />
End Sub<br />
<br />
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
End Sub<br />
<br />
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_brs_Copy.Click<br />
Dim folderBrowserDialog1 As New FolderBrowserDialog<br />
<br />
'Present the user with a file open dialog box.<br />
folderBrowserDialog1.ShowNewFolderButton = True<br />
If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then<br />
<br />
End If<br />
txt_copyLocation.Text = folderBrowserDialog1.SelectedPath<br />
End Sub<br />
<br />
Private Sub btn_brs_Backup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_brs_Backup.Click<br />
Dim folderBrowserDialog1 As New FolderBrowserDialog<br />
<br />
'Present the user with a file open dialog box.<br />
folderBrowserDialog1.ShowNewFolderButton = True<br />
If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then<br />
<br />
End If<br />
txt_backupLocation.Text = folderBrowserDialog1.SelectedPath<br />
End Sub<br />
<br />
Private Sub Button1_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
changed_files.Items.Clear()<br />
End Sub<br />
<br />
<br />
<br />
End Class<br />
<br />
Please e-mail if you have any questions or want the zip file.
erik4ever@gmail.com
|
|
|
|
|
Without spending much time on this...
This is just a guess but ..
Dim fs As FileStream = File.Create(path)
fs.Close()
Won't this create a blank file? You create the stream and close it without writing any data.
"People who never make mistakes, never do anything."
My Blog
|
|
|
|
|
So what is your solution, I mean I have tried moving this to the very end of my code (right after the "END TRY") and still nothing.
Please help, been struggling with this for 2 days now.
|
|
|
|
|
I figured it out. I didn't even need the "FILE STREAM" code in there, I removed it completely, and the fs.close() and it works GREAT NOW!. Look for a post to the articles section soon with whole program.
|
|
|
|
|
Hello!
I realized that the hide function of tabcontrol is not hidding the specific tabpage. Is there a way to enable/disable or hide/show a tabpage of tabcontrol instead of adding or removing it?
I am using VS 2005 and hide function is not working out with tabpages as shown below statement.
Tabcontrol1.tabpage(2).hide() <-- It is not hiding the tabpage
Thanks!
|
|
|
|
|
No, there isn't.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
Is there any method that can be used to return form to state where it was created for the first time( clear all the text box, rebinding all the control, etc ) without closing the form itself?
Thanks and regards,
WiL
|
|
|
|
|
No, there isn't. You have to write the code to reset all of this yourself.
Your only other option is to kill the current instance of the form and create a new one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi...
i want to know, if we have a .dll file, how do we call method inside it from VC++ 6.0?
thx...
-- modified at 4:23 Thursday 9th February, 2006
i'm sorry, hehehe... the real question is :
i have a custom TTS in dll form,
if i want to implement MS SAPI interface, so my custom TTS have the same interface with MS SAPI, what should i do?
thx...
|
|
|
|
|
Ask this in the Visual C++ Forum...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Pls help where can i download a free flexcell grid 2.0 .net
if you know some links where to download it.. it'll be a very great help....
Pls i need the link for free download for flexcell / flexgrid 2.0 .net.....
Thanks and more power
|
|
|
|
|
Google[^] is your friend. Get to know it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
in vb.net form, i have 1 text box and 1 command button
when user type in file name (no extension, just name) in the text box and click the button, it will open the file in a specific program (ex: winamp or wmp)
-click event:<br />
run winamp (or wmp) and play file with full path as "c:\data\ + file name (from text box) + .mp3"
help, please....
thanks a lot!
-- modified at 3:00 Wednesday 8th February, 2006
|
|
|
|
|
This will be a solution, if you make your application for you.
Name of the textbox is TextBox1
System.Diagnostics.Process.Start("c:\data\" & TextBox1.text & ".mp3")
You can use it, if Winamp is associated with mp3 files.
If not,
Right click on a mp3 file
Select open with.
Select Winamp from the list
Check Always use the selected program to open this kind of file
Click OK.
chatura
|
|
|
|
|
thanks, i got it done with your help.
|
|
|
|
|
i want to know the step by step process of database conectivity in vb.net
kaps
|
|
|
|
|