|
I think you've done this backwards. You can't close the form that your application started on without closing your Application. Make you startup form the MDIParent. When it starts, it needs to check to see if anyone has logged in successfully, if not, have it show the login form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm trying to learn how to do drag and drop. I wrote an applciation for a school project 2 semesters ago, but I want to add functionality to it. How would I go about dragging a file into a richtextbox, getting the path of the file that was dragged to open the file?
Thanks
|
|
|
|
|
I've never tried this so I thought I would give it a go. It was quite easy actually. There are plenty of articles on drag and drop on CodeProject and the Internet.
First you need to set the RichTextBox's property AllowDrop = True.
Next, you need to handle its DragEnter and DragDrop events.
Also, you're going to need to handle the case where the dragged file is not a TXT or RTF file. The below code does not handle this.
Private Sub txtField_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles txtField.DragEnter
' Validate.
If (e Is Nothing) Then Return
If (e.Data Is Nothing) Then Return
' Change mouse cursor if dragging a file over this control.
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub txtField_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles txtField.DragDrop
Dim fileName As String
' Validate.
If (e Is Nothing) Then Return
If (e.Data Is Nothing) Then Return
If (Not e.Data.GetDataPresent(DataFormats.FileDrop)) Then Return
' Get name of file that was dragged and dropped here.
fileName = DirectCast(e.Data.GetData(DataFormats.FileDrop), String())(0)
If (fileName Is Nothing) Then Return
If (fileName.Length <= 0) Then Return
' Output file's contents into RichTextBox.
Try
Dim reader As New System.IO.StreamReader(fileName)
If (fileName.ToLower.EndsWith("rtf")) Then ' Read RTF file.
txtField.Rtf = reader.ReadToEnd()
Else ' Assume it's a TXT file.
txtField.Text = reader.ReadToEnd()
End If
reader.Close()
Catch
End Try
End Sub
-- modified at 17:30 Sunday 20th November, 2005
|
|
|
|
|
I have a big problem. I'm using to create an example of Sending file to a cellphone,Nokia, through an UKD5 cable. However, my program can't recognize the model of the cellphone automatically, which is a problem. Besides, another problem is that I don't know how to send file to the cellphone, how to define the root folder of the cellphone. I'm in dark... Thanks a lot.
-- modified at 23:49 Friday 18th November, 2005
|
|
|
|
|
I would like to display an image file. How to do it using SDE
|
|
|
|
|
What's SDE? State Department of Education?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello2
I am having problem with coloring border of a textbox, can someone help me plz
Thank you
|
|
|
|
|
You can't color the border of the standard TextBox. It'll use the system colors when it draws itself. If you want this kind of functionality, you'll either have to find a 3rd party control library that supports this, or write your own TextBox control and draw it yourself.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm trying to write my own, i succeded in coloring the border, but when i try to write sth on the textbox, it's doing a weird thing. I think that's becoz i updated the styles so that the userPaint = true
Me.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, True)
Do you have another way?
|
|
|
|
|
eagertolearn wrote: but when i try to write sth on the textbox, it's doing a weird thing.
And that would be? You haven't said anything about what the problem is.
I, and everyone else, can't make a suggestion of what to change if I don't know what it's doing and don't know anything else about your code. Are you inheriting from the original TextBox? Creating you own control from scratch? Which class did you inherit from to start with? What do your painting code look like?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Woops, sorry
Ok, here's what it's doing. I got it to paint the border color. However, when i type sth, it will only type it but it doesn't let me delete or do anything else.
I inherit it from the TextBox class.
Add 2 properties to the class, borderColor and borderWidth.
And I draw the line using the pen Class
That's it. Is there sth i have to do extra?
Sorry, I'm new to this thing.
Thank you for your help
|
|
|
|
|
How to clone an object that has event handlers in it to get a copy of this object but not a pointer?
|
|
|
|
|
I don't quite understand what you are asking here.
Can you please rephrase the question?
|
|
|
|
|
Using VB.Net I created MustInherit Object in my project. This object must have public method Clone(byVal objectToCopy As Object). This method is very like:
Dim obj1 As New Object
Dim obj2 As New Object
obj2 = obj1
But in this case obj2 will have reference to obj1.
I need obj2 to be absolutely independent, so wherever happens to obj2, obj1 will stay the same.
I tried to use Serialization, but it doesn't work, because the object has event handler in it.
Thank you for your reply
|
|
|
|
|
You need to call the Clone() method to make a copy of an object.
Dim obj1 As New Foo<br />
Dim obj2 As Foo = DirectCast(obj1.Clone(), Foo)
But be aware that it'll only create a shallow copy. Meaning that the reference member variables in both the clone and source will still reference the same objects in the heap. If you want the clone's member references to refer to new objects/copies, then you'll need to clone its member variables too.
Public Class Bar : Implements ICloneable
Public Data As Integer ' Value types are always copied.
Public Function Clone() As Object Implements System.ICloneable.Clone
Return Me.MemberwiseClone()
End Function
End Class
Public Class Foo : Implements ICloneable
Public Bar As New Bar ' Referenced objects are not copied.
Public Function Clone() As Object Implements System.ICloneable.Clone
Dim copy As Foo = DirectCast(Me.MemberwiseClone(), Foo)
copy.Bar = DirectCast(Me.Bar.Clone(), Bar) ' Clone member object too.
Return copy
End Function
End Class
|
|
|
|
|
perfect. Thanks so much!
|
|
|
|
|
How do I Launch an HTML document in Internet Explorer using VB.net?
|
|
|
|
|
try this:
Process.Start("http://www.codeproject.com")
|
|
|
|
|
|
You already got your answer on the original post. Make absolutely sure your parameter types match. You've got a C function with an Int parameter declared as Int16 in VB. The C Int is 32 bits wide, while the VB Int16 is, obviously, 16 bits wide.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello all,
i am developing an application for a client where i have only the PST lines to communicate. but the database is there in server which is far a way from my site. i need to dial the data from client application and retreive the data. how do i do that from my client application.
Could any one plz suggest me plz.
Thanking u all.
regards,
Basheer.
|
|
|
|
|
I want to way in vb or batch file able to force domain user to logoff after their time has expired.
Or if there is another solution for this, pleas?
thanks
|
|
|
|
|
This question really belongs in a different forum.
You should be using donain group policies for this sort of thing. It's all done for you by Microsoft.
...Steve
|
|
|
|
|
Hi,
I am developing a VB.NET Windows App using VS 2003 and Framework 1.4.
The app bascially executes DTS packages on a remote SQL Server 2000.
One of the DTS packages deletes a database, however if there is a remote connection
to the database , the DTS package to delete it will fail, as expected.
Before the database is deleted I do some stuff with it:
Dim Conn As SqlConnection = New SqlConnection(ConnectionString)
Conn.Open()
'do some stuff
Conn.Close()
Conn.Dispose()
Conn = Nothing
After this code it attempts to delete the code using the remote call to the DTS package, but fails.
I have tested the DTS execution before connecting to the database with the code above and it works fine.
If I go into Enterprise Manager and look at the Process Info under Management/Current Activity/ I can see the new process id to the database created. I have done testing and as long as the process id to the database exists I can't delete the database.
What can I do to remove the processId from the SQL Server? The code above does not. When debugging, if I STOP the application , the process id disappears.
Can someone explain how to remove the connection from the server using VB code?
thanks
haggisns
|
|
|
|
|
haggisns wrote: One of the DTS packages deletes a database, however if there is a remote connection
to the database , the DTS package to delete it will fail, as expected.
One thing you might want to do to avoid running the DTS package if there is a connection to the database that would prevent you from deleting it is to check whether there are any connections. Something like this in the master database, where the number of rows returned indicates the number of connections to the database:
SELECT syslocks.id FROM syslocks, sysdatabases WHERE (syslocks.dbid = sysdatabases.dbid) AND (sysdatabases.name = 'your-database-name')
-- modified at 9:47 Friday 18th November, 2005
|
|
|
|