From: Robbie on 31 May 2010 22:09 Hi, I have a "keyboard" form that I would like to reuse through out my application... Let's say in Form1 I have a text box or property I want to populate... I want to be able to call the "FormKeyboard" which has a textbox that gets populated with the value typed by the user. I then want to transfer this value back to the Calling Form... How may I make "FormKeyboard" generic enough to be useable form any form ? Thanks
From: Tom Shelton on 31 May 2010 22:36 Robbie has brought this to us : > Hi, > > I have a "keyboard" form that I would like to reuse through out my > application... > > Let's say in Form1 I have a text box or property I want to populate... I want > to be able to call the "FormKeyboard" which has a textbox that gets populated > with the value typed by the user. I then want to transfer this value back > to the Calling Form... > > How may I make "FormKeyboard" generic enough to be useable form any form ? > > Thanks There are a number of ways to accomplish this... A form is just a class. You can expose custom properites, methods, and events to clients of this form just as you would any other class. -- Tom Shelton
From: Mr. Arnold on 31 May 2010 23:57 Robbie wrote: > Hi, > > I have a "keyboard" form that I would like to reuse through out my > application... > > Let's say in Form1 I have a text box or property I want to populate... I > want to be able to call the "FormKeyboard" which has a textbox that gets > populated with the value typed by the user. I then want to transfer this > value back to the Calling Form... > > How may I make "FormKeyboard" generic enough to be useable form any form ? > You use a MVP (Model View Presenter) design pattern to make it generic, and you use objects. The object that holds the data properties is passed between classes, a form.vb is just another class.
From: Robbie on 1 Jun 2010 01:04 Hi, Specifically... Public Class KeyboardInputs Private m_KeyboardSend As String Public Property KeyboardSend() As String Get KeyboardSend = m_KeyboardSend End Get Set(ByVal value As String) m_KeyboardSend = value End Set End Property End Class 'This is the code in the Keyboard that sends the typed value to KeyboardInputs.KeyboardSend Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click Dim objKeyboardInputs As New KeyboardInputs objKeyboardInputs.KeyboardSend = txtFormValue.Text MsgBox("objKeyboardInputs.KeyboardSend " & objKeyboardInputs.KeyboardSend) Me.Visible = False End Sub Now How do I get this back to the calling Form (generically) without making a reference to the specific form name ? "Mr. Arnold" <Arnold(a)Arnold.com> wrote in message news:%23C2qg6TALHA.5476(a)TK2MSFTNGP06.phx.gbl... > Robbie wrote: >> Hi, >> >> I have a "keyboard" form that I would like to reuse through out my >> application... >> >> Let's say in Form1 I have a text box or property I want to populate... I >> want to be able to call the "FormKeyboard" which has a textbox that gets >> populated with the value typed by the user. I then want to transfer >> this value back to the Calling Form... >> >> How may I make "FormKeyboard" generic enough to be useable form any form >> ? >> > > You use a MVP (Model View Presenter) design pattern to make it generic, > and you use objects. The object that holds the data properties is passed > between classes, a form.vb is just another class. >
From: Jason Keats on 1 Jun 2010 10:41
Robbie wrote: > > Now How do I get this back to the calling Form (generically) without making > a reference to the specific form name ? > You need to find an example that includes the statements/terms: "Private WithEvents" "Public Event" "RaiseEvent" The first hit in a search using the above provides the following link: http://devcity.net/Articles/25/1/20020316.aspx It's not ideal, but it does illustrate how to call a class/form using WithEvents, how to define events using "Public Event" and how to send information back to the calling class/form by using RaiseEvent. |