(NET) NET (2019)

3.1. My typical VB.NET desktop application. How to overcome VS Designer lost link to controls.

Usually VS Designer lost link to form control in code. EmailCenterSubformDataGridView will be not accessible in form core.



For overcom this issue I create a separate file with definition of forms components deleted by designer.



And use this extension

   5:      <Extension()>
   6:      Public Function FindRecusriveByType(ByVal control As Control, ByVal type As Type) As IEnumerable(Of Control)
   7:          Dim controls = control.Controls.Cast(Of Control)()
   8:          Return controls.SelectMany(Function(ctrl) FindRecusriveByType(ctrl, type)).Concat(controls).Where(Function(c) c.[GetType]() = type)
   9:      End Function

to restore link between form code and code designer.

  15:          EmailCenterSubformDataGridView = Me.FindRecusriveByType(GetType(DataGridView)).First
17: AttachmentListListView = Me.FindRecusriveByType(GetType(ListView)).First

Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/Samantha/DesignerLostLink.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>