|
Hi,
I would like to get filenames from a directory and populate its name and icons in a listview.
I tried for the filename and succeded.
Private Sub PopulateData()
Dim FilePath As String = Application.StartupPath & "\users\"
Dim ContentItem As String = Dir(FilePath & "*.dat")
ListView1.Items.Clear()
If ContentItem = "" Then
MsgBox("No users found.")
End If
Do Until ContentItem = ""
ListView1.Items.Add(ContentItem)
ContentItem = Dir()
Loop
End Sub
and I am populating the listview in form loading event.
Private Sub FormCreateUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PopulateData()
End Sub
"users" is a folder from where I want to get the filename details.
But I want to get the file icons also and I don't know how to do this.
Please help.
modified 17-Jul-13 13:41pm.
|
|
|
|
|
Files do not have icons, that is just a mechanism used by Windows Explorer to help provide visual identification of different types of files. You could get the icons out of explorer, or creatre your own, and save them in your program then use the same criteria to add them to your listview. However, since you are only searching for files with the .dat extension there seems little point in having the same icon on each entry.
Use the best guess
|
|
|
|
|
|
Hi, i have a database with the following details:
SCHOOL CAMPUS ADMINNO MODULECODE MODULEGRP
SEG AMK 100810R EG3932 EG3932-G1
SEG AMK 100810R EG3933 EG3933-G1
SEG AMK 101427Y EG3901 EG3901-G1
SEG AMK 101427Y EG3902 EG3902-G1
SEG AMK 101427Y EGS650 EGS650-G1
SEG AMK 103852S EG3901 EG3901-G1
SEG AMK 103852S EG3904 EG3904-G1
now i managed to get distinct students(adminno), modulecode(subject) populate in a datagrid
also, module-students in dgv which looks like:
EG1001 ---- Student 1
----------- Student 2
----------- Student 3
EG1002 ---- Student 2
----------- Student 4
But now i want to achieve:
Modulecode --- ModuleGrp ---- numberofstudents ---- students adminno
EG3932 ------- G1 ----------- 58 ------------------ 111411H 11253U 178292I...
Can anyone advice how can i go about achieving this?
Listview? or multi Line textbox? or other choices?
using vb.net, SQL commands with OleDB to retrieve data.
Thanks in advance!
|
|
|
|
|
12345_abcde wrote: Can anyone advice how can i go about achieving this? Listview? or multi Line textbox? or other choices? A DataGridView
Roughly the same code as the previous exercise, but a different query. A complex one at that, since your data doesn't look normalized. And from which table would "NumberOfStudents" come? Not the one from the example-table.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi all,
I'm a newbie at VB.net,
I want connect to access via VB.net and manager two table with a relation type "master-child",
Master table named "Book" consists of three columns: BookID [AutoNumber], Author [Text], Description [Text],
Child table named "Chapter" with three columns: ChapterID [AutoNumber], BookID [Number], Title [Text],
Then I create an application VB.net that has one main window using a dataset with two table Book and Chapter. I make a relation between them, from BookID in the table Chapter to BookID in the master table. I use a databindingsource to manager them, the table Book is displayed by a form detail, the Chapter by a datagridview. When I delete a row in Book-table, I also want delete all chapter located it. I tried to use Tableadapter but the chapters were not deleted.
Help me,
|
|
|
|
|
When you create / edit the table definitions, make sure that you set referential integrity with "OnDeleteCascade". Then the database will handle that.
|
|
|
|
|
im working on a project at the moment and i am facing a critical problem.
The tool that i have created using vb.net vs 2010 ultimate opens a "webbrowser" inside a windows form
this webbrowser displays a combination of not static banners from another server.
These banners hav an onclick event that opens a webpage.
For example : if you click on the puma banner, IE browser opens the official puma page.
My problem is that when it is opening with IE, no problem at all. The page is opening and loading normally.
whenever i use the "Process.Start(e.ToString())" to open it with the default browser,the default browser launches but with
url: System.ComponentModel.CancelEventArgs
the function is so simple to write but somehow, i am not able to assign a e.url.tostring to the process.start knowing that im using it in the newwindow event.
in the newwindow event, if i change the definirion of e as System.ComponentModel.CancelEventArgs to e as System.Windows.Forms.WebBrowserNavigatingEventArgs then it will always open with IE
i have been trying every single solution i could think of or found online so far and still ... it either opens with IE perfectly (which is not what i want- should be in default browser) Or the default browser launches onclick to the homepage of the browser.
Is there any way to record the URL called in the popup IE window and save it somewhere to be able to browse it using the process.start Or is there another way to do that.
Im kinda getting frustrated from this already
Your help will be highly appreciated
Roy
|
|
|
|
|
You're launching the CancelEventArgs object (converted to a string). You're not supplying a URL to launch. What event are you handling that you've put this Process.Start code into?
|
|
|
|
|
yes i know i am not passing a url through.
Thats my exact question .... how can i catch the url of the window that is opening in IE so i can launch it from anywhere i want to !
Regarding the events, i am stopping the Ie from opening via e.cancel = true in the newwindow event
and then i tried on the navigating to run process.start(e.url.tostring())
|
|
|
|
|
Considering CancelEventArgs doesn't have a URL property, what you're doing isn't going to work.
You can try to handle the NewWindow or Navigating events of the WebBrowser control. I suggest reading up on those events to see exactly what they do, what argument they expose and what the properties of those arguments are before you proceed.
|
|
|
|
|
Public Delegate Sub NewWindowExtendedEventHandler(ByVal sender As Object, ByVal e As NewWindowExtendedEventArgs)
Public Class NewWindowExtendedEventArgs : CancelEventArgs
Private url As Uri
Public ReadOnly Property Url As Uri
Get
Return url
End Get
End Property
Public Sub New(ByVal url As Uri)
Me.url = url
End Sub
End Class
Public Class ExtendedWebBrowser
Inherits WebBrowser
Private Class WebBrowserExtendedEvents
Inherits System.Runtime.InteropServices.StandardOleMarshalObject
Implements DWebBrowserEvents2
Private browser As ExtendedWebBrowser
Public Sub New(browser As ExtendedWebBrowser)
Me.browser = browser
End Sub
Public Sub NewWindow3(pDisp As Object, ByRef cancel As Boolean, ByRef flags As Object, ByRef urlContext As String, ByRef url As String) Implements ExtendedWebBrowser.DWebBrowserEvents2.NewWindow3
Dim e As New NewWindowExtendedEventArgs(New Uri(url))
browser.OnNewWindowExtended(e)
cancel = e.Cancel
End Sub
End Class
<ComImport> _
<Guid("34A715A0-6587-11D0-924A-0020AFC7AC4D")> _
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)> _
<TypeLibType(TypeLibTypeFlags.FHidden)> _
Private Interface DWebBrowserEvents2
<DispId(273)> _
Sub NewWindow3(<InAttribute, MarshalAs(UnmanagedType.IDispatch)> pDisp As Object, <InAttribute, OutAttribute> ByRef cancel As Boolean, <InAttribute> ByRef flags As Object, <InAttribute, MarshalAs(UnmanagedType.BStr)> ByRef urlContext As String, <InAttribute, MarshalAs(UnmanagedType.BStr)> ByRef url As String) Implements ExtendedWebBrowser.DWebBrowserEvents2.NewWindow3
End Interface
Public Event NewWindowExtended As NewWindowExtendedEventHandler
Private cookie As AxHost.ConnectionPointCookie
Private wevents As WebBrowserExtendedEvents
Protected Overrides Sub CreateSink()
MyBase.CreateSink()
wevents = New WebBrowserExtendedEvents(Me)
cookie = New AxHost.ConnectionPointCookie(Me.ActiveXInstance, wevents, GetType(DWebBrowserEvents2))
End Sub
Protected Overrides Sub DetachSink()
If cookie IsNot Nothing Then
cookie.Disconnect()
cookie = Nothing
End If
MyBase.DetachSink()
End Sub
Protected Overridable Sub OnNewWindowExtended(e As NewWindowExtendedEventArgs)
RaiseEvent NewWindowExtended(Me, e)
End Sub
End Class
Hope this helps. I just converted this from the C# code in #Develop. It allows for getting the URL of the event.
brisingr_aerowing@Gryphon-PC $ rake in_the_dough
Raking in the dough
brisingr_aerowing@Gryphon-PC $ make lots_of_money
Making lots_of_money
|
|
|
|
|
Hi all, I want to create a Windows service that detect system datetime change and as soon as it detects the change, it gives a message "System DateTime has been changed".
Public Class CltChk
Protected Overrides Sub OnStart(ByVal args() As String)
End Sub
Protected Overrides Sub OnStop()
End Sub
Private Sub CheckDateTimeClock()
Dim SysTime As Date = Date.Now
Dim CurrentHour As Integer = SysTime.Hour
Dim CurrentMinute As Integer = SysTime.Minute
Dim CurrentSecond As Integer = SysTime.Second
Dim CurrentMilliSecond As Integer = SysTime.Millisecond
End Sub
End Class
I created a windows service but I don't know how to start.
Please HELP me.
modified 9-Jul-13 8:36am.
|
|
|
|
|
Member 7815124 wrote: a Windows service ... it gives a message "System DateTime has been changed".
A Windows service cannot interact with the desktop, so it's not going to be able to display a message to the user. There might not even be a user logged in when the system time changes.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for your quick answer.
So what am I to do ? Creating a windows process that runs in background ? What should be the code ?
I have written something please check it.....
Public Class Form1
Dim iDate As DateTime = DateTime.Now
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim iDateNow As DateTime = DateTime.Now
If iDateNow <> iDate Then
MsgBox("Date Time Change Detected.")
End If
End Sub
End Class
Is the above code OK ? How should I run it like a process ?
modified 9-Jul-13 7:53am.
|
|
|
|
|
That code is going to pop up a message every second. If you leave it running, it will fill your screen with messages, and eventually exhaust all system resources.
What are you actually trying to achieve?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, First I should tell you that I am not getting any message running this code(I do not know why? is it that I am not using a loop?).
Secondly and most important thing is I am trying to create something that detects System Date Time change and give a message to the user. This program will be connected to my main program i.e. if this program/process is closed then the main program will be closed automatically.
My main program contains a piece of code that writes install date, License period and last use date in the registry. If the user try to manipulate the system date and time my main program will not open (Although the idea or the code is not fullproof)
So I want to warn user through the detection of dateTime change that, to get back the last date time otherwise the program will not run.
|
|
|
|
|
There is no reliable way to do this without using an external clock source, such as one on the Internet.
The only place I know of to get that the system time changed would be from the System Event Log. Still, even the event log can be cleared out without your code ever seeing the event.
Monitoring for it and watching the time contantly isn't going to do you any good. What if the system time changes when Windows isn't running??
The only way to do it would be to compare the current system time to an external reference and make a note of the offset. Every once in a while (while your code is running) you'll have to compare the current time to the external source again and see if the time is current, again, considering the offset you noted before, plus or minus a variance. PC clocks don't run at exactly the same speed and will drift over time.
|
|
|
|
|
|
Simple to reroute using the host-file
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Even if you use the IP address?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you all for your quick answers. But I should inform you that I am not so much educated in vb.net like you all. Therefore believe me your answers are just like a Tangent for me.
Ok, let me state you my idea which i would like to implement
1. My process starts with windows (continuously checking the system date and time and matching.)
2. User starts main program (checks if the process is running.)
Somehow user understood and find that the process is responsible for date time checking. So he close the process from windows task manager.
3. My process close my main program before closing.
4. User wants to start main program. (Main program checks and found process is not running)
5. Main program will not run.
I tried to create the process and tried to close Microsoft Word with that but failed......
Imports System
Imports System.Diagnostics
Public Class Form1
Dim iDate As DateTime = DateTime.Now
Dim MyProcess() As Process = System.Diagnostics.Process.GetProcessesByName("winword")
Sub New()
InitializeComponent()
Timer1.Interval = 1000
Timer1.Enabled = True
Application.Run()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim iDateNow As DateTime = DateTime.Now
If iDateNow < iDate Then
For Each p As Process In MyProcess
p.Kill()
Next
End If
End Sub
End Class
While I tried to close the process, Microsoft word was not closing.
|
|
|
|
|
Biplob Singha Shee wrote: While I tried to close the process, Microsoft word was not closing.
You've not added any code to kill the process when your application exits. You'd need to do that from the Closing event of your form.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I wrote the code to kill the process
For Each p As Process In MyProcess
p.Kill()
Next
and before that I declare the variable
Dim MyProcess() As Process = System.Diagnostics.Process.GetProcessesByName("winword")
|
|
|
|
|
But in the code you posted, there is nothing which will run when the form is closed. The only time your p.Kill() code will execute is if the system time is changed to be earlier than the start time of your program.
The only time that will normally happen is when the computer transitions out of Daylight Saving Time, when the clocks go back by one hour. (Since that's not the issue you're trying to address, you should be using DateTime.UtcNow instead.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|