|
Yep, sorry I missed over that, those links will still help you out (to the OP)
|
|
|
|
|
ok..so should it be something like this
in child class..
In child form...
Public Class1
Public Event addtolist (Byval s as string) '' s is what is to printed in the listbox in parent class
'
Private sub()
dim obj as new class1
addhandler obj.addtolist,address of class2.addtolistbox
' some code
'
'
RaiseEvent addtolist(s) 'where i want to add to the listbox in parent form
'
'
End Sub
End Class1
In parent form.....
public class2
public sub addtolistbox(ByVal sender As Object, _
ByVal e As System.EventArgs)
listbox1.items.add(e.argument)
end sub
end class2
Is this how what you mean Dave?
EliottA,thanks for the comments and links.they were useful
|
|
|
|
|
OK, last time...
The CHILD form exposes the public Event and calls RaiseEvent when it needs a subscriber to know of a change. This much you got right. The child form does NOT use AddHandler and RemoveHandler on it's own events because it's not subscribing to itself.
The PARENT form needs to call AddHandler to subscribe to the events exposed by the child form. But, it can only do this if the parent form has a method that matches the header exposed by the event AND has an child form object (an instance of a class is called an "object"). So, after your parent form creates a child form object, it calls AddHandler to wire up the event exposed by the child form object to the method in the parent form that handles the event.
|
|
|
|
|
|
Thanks for description dave..
ok..so should it be something like this..i am sorry I havent tried it yet because visual studio is on my other laptop that I dont have with me right now..so just doing some research on it..I'll try it as soon as i get have it.
In child form...
Public Class1
Public Event addtolist (Byval s as string) '' s is what is to printed in the listbox in parent class
'
Private sub()
' some code
'
'
RaiseEvent addtolist(s) 'where i want to add to the listbox in parent form
'
'
End Sub
End Class1
In parent form.....
public class2
public obj as new class1
addhandler obj.addtolist,addressof addtolistbox
public sub addtolistbox(ByVal sender As Object, _
ByVal e As System.EventArgs)
listbox1.items.add(e.argument)
end sub
end class2
Just one thing i didn't get..sorry to bother you..
"it can only do this if the parent form has a method that matches the header exposed by the event",I don't know what you meant by this.
Do you mean the method in the parent form that handles the event should have the same name as the event ie; 'addtolist'?
|
|
|
|
|
Yeah, pretty much got it. Except for one thing:
public sub addtolistbox(ByVal sender As Object, _
ByVal e As System.EventArgs)
This is wrong. Like I said, the method signatures have to match. So, you event is defined like this:
Public Event addtolist(ByVal s as string)
so your event handler has to look the same:
Private Sub AddToListbox(ByVal str As String)
You don't have to have the same variable names, just the same types in the same order.
|
|
|
|
|
i tried it the way you said but it isn't working.
In the parent form, I created on object of the child form and put the AddHandler syntax in the form load sub.
|
|
|
|
|
What do you mean "it isnt' working"? What IS happening? Have you steped through the code using the debugger to see where it's going and what it's doing??
|
|
|
|
|
Yes I have done it..when it reaches the RaiseEvent it doesn't go the event handler..it just goes to the next line.
|
|
|
|
|
That would probably be because there is nothing subscribed to the event.
|
|
|
|
|
well I have done exactly as you said.
This is in the parent form,I have added this in the form load event of the parent form
Dim obj1 As New childform
AddHandler obj1.addtolist, AddressOf addtolistbox
and this is sub that is subscribed to the event..
Private Sub addtolistbox(ByVal str As String)
ListBox1.Items.Add(str)
End Sub
In the child form....
Public Event addtolist(ByVal s As String)
and in the sub where I want to add to listbox in parent form,
RaiseEvent addtolist(ds1.Tables(0).Rows(0)("Reader_location").ToString & " Connected ")
|
|
|
|
|
salam sir;
how can made login form in vb6 and vb.net?please send me coding
thanks sir
mohammedali
|
|
|
|
|
1. Cross post
2. We don't do your work for you
3. This can easily be found on the internet.
Blog link to be reinstated at a later date.
|
|
|
|
|
Damn dude, don't spam the boards. Doesn't VB.NET express 2008 have a login form template for Christs sake??
|
|
|
|
|
Awesome question!
snicker..snicker..
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
whats worse is he asked this question months ago. Same project or did he retake the course?
10:1 its the same project
.5:1 its a redo on the course
Any takers?
|
|
|
|
|
I'd bet on the same proj. Sad really...
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Ill tell you whats sad.
1. The person who is going to take this project and will generally accept it as being either
a) secure
b) complete
c) efficient
Even if this project is for himself, I can see the hard coded plain-text password in a form1.cs (or form1.vb) file.
I hope no one is paying for this. Moreover I hope this IS for a class, that way he will actually get correction and maybe direction.
|
|
|
|
|
I noticed that too. I'm guessing retake of the course.
Blog link to be reinstated at a later date.
|
|
|
|
|
How many times are you going to ask this until you realize that noone is going to send you anything?? This is so easy to research on the web, it's silly. You say you're a Computer Engineering student, but you don't know how to do research?? That's THE most important skill you MUST have when working in this field...
|
|
|
|
|
I won't send you the code, but here are some tips
- Always use plaintext passwords. Hashing takes too long
- Make the username case-sensitive. People love that
- Color the login form yellow, green and purple. No-one will hack it if you do that
- Wouldn't it be convenient if the users could have a little dog or paperclip to help them log in?
|
|
|
|
|
In my VB code
Dim MyNewRow As DataRow
MyNewRow = Me.DataSet1.Tables(0).NewRow()
MyNewRow.Item("reason-code") = "RX6"
MyNewRow.Item("description") = "Hello from VB"
MyNewRow.Item("sl-paid") = True
MyNewRow.Item("sp-paid") = False
Me.DataSet1.absence.Rows.Add(MyNewRow)
Me.AbsenceTableAdapter.Update(Me.DataSet1.absence)
but ony first field "RX7" gets into the data base
any help would be appreciated
|
|
|
|
|
First, which version of Visual Studio are you using? Did you create a Typed DataSet using the designer? Also, what does the SQL looks like that you're using in the AbsenseTableAdapter? Does this database table have a PrimaryKey??
|
|
|
|
|
VS2005, this is an ODBC connection to a Progress database, and yes the table does have a primary key..on the 'reason-code' field, which looking at the code was the only field in update statement... I deleted all and tried again, but now I can't even get it to to do an update.
So I added an insert query and that worked just fine.
|
|
|
|
|
OK, great! But, my only concern is "Reason Code" doesn't sound like a good candidate for a PrimaryKey. It would seem that there could be multiple records in the table with the same reason code. This is not a good situation where the PK has to be able to uniquely identify every record in the table, which is a requirement for the TableAdapter to work.
|
|
|
|