more events

hi.

this code is inside a custom dgv.

PrivateWithEvents mynavigatorAs BindingNavigator

PublicWithEvents mySaveAs Windows.Forms.ToolStripButton

PrivateSub DGV_GotFocus(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.GotFocus

Me.mynavigator = MainMenu.mynav

mynavigator.BindingSource =Me.DataSource

Me.mySave = MainMenu.mySave

EndSub

PublicSub mySave_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles mySave.Click

MsgBox("saving")

EndSub

this is inside main menu

PublicClass MainMenu

Inherits FormTemplate

PublicShared mynavAsNew Mynavigator

PublicShared mySaveAs ToolStripButton

Public FormsAsNew List(OfString)

PublicSub NewForm(ByVal FAs Form)

If Forms.Contains(F.GetType.ToString)Then

F.BringToFront()

Else

Me.Forms.Add(F.GetType.ToString)

F.Show()

AddHandler F.FormClosing,AddressOf Form_Closing

EndIf

EndSub

PublicSub Form_Closing(ByVal sAsObject,ByVal eAs FormClosingEventArgs)

mynav.BindingSource =Nothing

mySave =Nothing

EndSub

PublicSubNew()

InitializeComponent()

mynav =New Mynavigator

mySave = mynav.SaveToolStripButton

Me.Controls.Add(mynav)

EndSub

EndClass

example of a form using these

PublicClass myAmountTypesManager

PrivateWithEvents mysaveAs ToolStripButton

PrivateSub saveBtn(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles mysave.Click

MsgBox(1)

Me.Validate()

DataAccess.SaveSource(Me.AmountTypesBindingSource, _

Me.CostingDataSet.AmountTypes,Me.AmountTypesTableAdapter)

EndSub

PrivateSub myAmountTypesManager_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load

Me.mysave =Me.AmountTypesDGV.mySave

Me.AmountTypesTableAdapter.Fill(Me.CostingDataSet.AmountTypes)

EndSub

EndClass

saving is not working.. msgbox 1 not firing. why?

[8802 byte] By [hrubesh] at [2007-12-24]
# 1

overview

mynavigator - has save button

mainmenu - has mynavigator and a mysave that points to mynavigator.savebutton

now mydgv has its own savebutton (not displayed) that is initialised on mydgv_hasfocus. that points to mainmenu.mysave

now each form created with mydgv dragged and drop should have their own save method.

that is executed when the navigators save button is pressed.

hrubesh at 2007-8-31 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...