• (2 Pages)
  • +
  • 1
  • 2

Passing Data Between Forms Rate Topic: ***** 1 Votes

#16 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3822
  • View blog
  • Posts: 13,544
  • Joined: 12-December 12

Posted 09 November 2013 - 10:46 AM

The vast majority of questions on this forum, and others, is still about WinForms, not WPF. Similarly, communicating between these forms is a very common question. The idea that a rookie would be data-aware (or even database-aware) enough to begin their journey at the level that you indicate is unrealistic. How would such a tutorial go? What level of understanding would the reader have to already have before they could follow the tutorial?

We are talking about rookies. They have to start somewhere ;). The approaches I outline in my tutorial are still a major step away from TextBox1 talks to TextBox2 on Form2. I hope that it also, to some extent, leads the reader towards the concept of data-objects (data-binding, the Entity Framework, etc.).

This post has been edited by andrewsw: 09 November 2013 - 10:50 AM

Was This Post Helpful? 1
  • +
  • -

#17 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5676
  • View blog
  • Posts: 12,199
  • Joined: 02-June 10

Posted 09 November 2013 - 06:13 PM

You're not wrong. And I didn't mean to sound like I was saying "You shouldn't have written this", if that's the way it came out. The tutorial absolutely addresses a large number of questions we get and certainly will be something I link to rookies asking these basic questions.

WinForms will remain the majority of questions for us for YEARS to come, because the base of established users will outnumber the users taking up the new technology. Plus books on WinForms are more plentify. Plus tutorials elsewhere are more plentiful. Plus schools have established curriculums based on WinForms. There is a lot of WinForms inertia in place.

By the same token, there are still a large number of Visual Basic 6 questions that get asked, despite it being a 10 years dead language. That doesn't mean it is a technology I would recommend to someone to start picking up today.

But that doesn't change the fact that WinForms is the old technology. I just went through a change of employment. I spent 9 years with a company doing WinForms, with the last two as a move over to WPF on a slow and limited scale. EVERY prospective employer wanted at least 5 years professional experience in WPF, solid testable skills in MVVM, experience with control templates and data templates.

I'm not saying this is a bad tutorial. I'm not trying to chastise you. I'm saying it is a good tutorial. But I would have felt remiss if I did not point out to those same rookies this targets that WPF, not WinForms is what is going to get them the better job with more future in it.

Since it is *all* equally new, why not start with proper WPF/MVVM, especially since it is the right GUI-to-Data model? Learn the right thinking from the start and you don't have to change and unlearn later.

Think of it like learning to drive. If you learn to drive a stick-shift pickup you're golden. Going to a motorcycle is the same manual shifting concepts. Switching down to an automatic compact is easy. But if you learn on an automatic compact, you have to learn new skills to drive the stick-shift, and unlearn the thinking of how small your car is when you move up to a big truck.

I didn't mean to hijack the thread so let me end on this... This is a great tutorial for a subject we get lots of questions about. And for anyone reading this: If you are in school learning WinForms then this is very much exactly what you probably need, in a well explained way. Andrew knows his stuff so listen to him; and if you are still in WinForms then this should help you a lot.
Was This Post Helpful? 1
  • +
  • -

#18 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3822
  • View blog
  • Posts: 13,544
  • Joined: 12-December 12

Posted 10 November 2013 - 04:11 AM

View PosttlhIn`toq, on 10 November 2013 - 01:13 AM, said:

You're not wrong. And I didn't mean to sound like I was saying "You shouldn't have written this", if that's the way it came out. The tutorial absolutely addresses a large number of questions we get and certainly will be something I link to rookies asking these basic questions.

No, that's fine, I didn't mis-interpret what you were saying, and I understand the points that you are making.

I didn't want the reader to be confused though, or to think that this tutorial could have be written in a different way - covering the same points, and at the same level.
Was This Post Helpful? 0
  • +
  • -

#19 Michael26  Icon User is online

  • DIC-head, major DIC-head
  • member icon

Reputation: 362
  • View blog
  • Posts: 1,539
  • Joined: 08-April 09

Posted 10 November 2013 - 07:59 AM

They don't have to spend 10.000 hours to learn old technology, but just enough to maintain legacy application, old technology like WinForms isn't gonna disappear just like that lots and lots will need to maintained and someone needs to do it.
Was This Post Helpful? 1
  • +
  • -

#20 bergeronjc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 29-October 13

Posted 13 November 2013 - 11:40 AM

So this is all vastly interesting and I was getting everything, even debugging some of my mistakes until the end with the color change.

Dim ColorValue As Color


The error says: Structure 'Color' cannot contain an instrance of itself: 'Color contains 'Color' (variable 'ColorValue').
The error correction options give me: Change 'Color to 'Drawing.Color' or Delete the line of code.

If I change to 'Drawing.Color' all of the Dim Colors() in frmChildColor get an error that states:
'Red' is not a member of 'Passing_Data_Between_Forms.Color'. (and the same for blue and green with their names in place of red).

So from that error correction I choose 'generate a field' for each color because it asks me if I want to generate a method stub or a field. However when I run the program clicking on the colors does absolutely nothing.

I am guessing that it doesn't know I want to change the background color or how it should change it based with the code presented. Is that true? If so how should the code read?
Was This Post Helpful? 0
  • +
  • -

#21 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3822
  • View blog
  • Posts: 13,544
  • Joined: 12-December 12

Posted 13 November 2013 - 11:45 AM

I deliberately named the structure Colour with a u (UK spelling) to avoid such issues:

Public Structure Colour
    Dim ColourName As String
    Dim ColourValue As Color

    Public Overrides Function ToString() As String
        Return ColourName
    End Function
End Structure

Was This Post Helpful? 1
  • +
  • -

#22 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5676
  • View blog
  • Posts: 12,199
  • Joined: 02-June 10

Posted 16 November 2013 - 06:57 AM

View PostMichael26, on 10 November 2013 - 08:59 AM, said:

They don't have to spend 10.000 hours to learn old technology, but just enough to maintain legacy application, old technology like WinForms isn't gonna disappear just like that lots and lots will need to maintained and someone needs to do it.


I guess that's the real question then... Do you want to be the guy that gets hired to maintain legacy projects, or do you want to be the guy whose skill-set puts them on the team for forward-thinking projects.

And frankly, there are so many people that have been doing WinForms for decades there won't be a shortage of people to do maintenance. Trying to add yourself to that pool is just silly. A working knowledge is good. Most likely the company with the legacy programs already has a team of legacy people to maintain them. As the new projects replace the old projects the people will either further their skill to move with the new technology, or the legacy coders will leave one by one as their projects get mothballed, for other legacy support positions.
Was This Post Helpful? 0
  • +
  • -

#23 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3822
  • View blog
  • Posts: 13,544
  • Joined: 12-December 12

Posted 16 November 2013 - 09:51 AM

Quote

As the new projects replace the old projects

This seems to suggest that companies are, en masse, migrating from WinForms to WPF, and that no new projects, or major projects, will be started with WinForms. Do we know this to be the case? Are there any resources that would tell us how quickly WPF is being adopted, and WinForms being side-lined?

I don't know myself, but I would be interested to discover such statistics.
Was This Post Helpful? 0
  • +
  • -

#24 nighttrain  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 383
  • Joined: 22-September 10

Posted 26 October 2014 - 03:15 AM

could you also describe situation when we have tw completly separated forms how to execute some method inside second form when first form raises an event ?
Was This Post Helpful? 0
  • +
  • -

#25 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5676
  • View blog
  • Posts: 12,199
  • Joined: 02-June 10

Posted 26 October 2014 - 07:05 AM

As for the migration from WinForms to WPF...

I don't know of any compiles statistics but I can speak to nature of this in the work place. I've worked for one of the largest thrill-ride software developers (Ride a roller coaster, buy your photo), and for Clear Channel Radio. In both of these 'big boys' the push is for WPF. Also both of these companies deal with other companies; for example when doing ride photography we would interact with point-of-sale software makers... And everyone we interact with is making the same push to migrate to WPF.

The other resource to look at for this is the job postings. Just read through them for WPF & MVVM. I'm job hunting right now after moving and am scrubbing through all the postings daily and vast majority of desktop jobs require multiple years of experience with WPF.

In some ways WPF is starting to be left behind for Web API and Web App development. Where possible companies are wanting to NOT have desktop application but open a browser to a web app. Clearly not all areas lend themselves to that, but more and more are pushing that way. Tech support people don't have local desktop applications that walk them through helping the customer, they have a web app they load... Insurance agents, hair salon appointments... Its all just data coming from a server and much of it can be done as web apps so there is nothing to install on a PC. That's attractive to business. Just buy a PC and start a web browser that points to their server: Keeping all the power and updating at the top in one place.

Quote

could you also describe situation when we have tw completly separated forms how to execute some method inside second form when first form raises an event ?


See FAQ # 6 below

TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 6: How do I make Class1/Form1 talk to Class2/Form2


FAQ (Frequently Asked Questions - Updated July 2014
Spoiler

This post has been edited by tlhIn`toq: 26 October 2014 - 07:07 AM

Was This Post Helpful? 0
  • +
  • -

#26 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3822
  • View blog
  • Posts: 13,544
  • Joined: 12-December 12

Posted 26 October 2014 - 07:28 AM

View Postnighttrain, on 26 October 2014 - 10:15 AM, said:

could you also describe situation when we have tw completly separated forms how to execute some method inside second form when first form raises an event ?

Yes, you could follow this up with tlhIn`toq 's tutorial Quick and Easy Custom Events. It is in C# though.

This post has been edited by andrewsw: 26 October 2014 - 07:31 AM

Was This Post Helpful? 1
  • +
  • -

#27 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3822
  • View blog
  • Posts: 13,544
  • Joined: 12-December 12

Posted 07 November 2014 - 02:33 PM

View Postnighttrain, on 26 October 2014 - 10:15 AM, said:

could you also describe situation when we have tw completly separated forms how to execute some method inside second form when first form raises an event ?

I do now have a tutorial for this but it is also, I'm afraid, in C#

Example: Delegate, Event And Custom EventArgs

I did start out with the intention of writing it in VB.NET, but the example I found that was most useful (as a starting point) was in C#. I forgot to switch to VB ;). Well.. I was probably just a bit lazy ;)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2