From a post from the VB.NET mailing list at Yahoo:

I want my windows form to draw a line automatically when the form loads. To do this i am trying the following code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
 Handles MyBase.Load

        Dim g As Graphics = Me.CreateGraphics

        g.DrawLine(SystemPens.ControlDarkDark, 10, 10, 50, 100)

        g.Dispose()

End Sub


but the line is not seen on the form! This code runs perfectly fine if i put it behind a button or other events but not on form loading. What should i do to make a line appear on form load?


I've ranted before and I'll rant again... Why should simple html tasks be so difficult? Really, what's the advantage of putting another layer (Web Forms and C#/VB.NET) between you and the code (html/javascript) you're making? For simple forms, etc, where you'd like to reuse some Windows.Forms code, I can see using the .NET web forms. But if something doesn't work the way you'd like after one shot, you really should kick the project to a web developer and use codebehind to seperate UI from logic -- or, imagine this, learn html!

I think there are still quite a few lessons to learn from asp.net programming.

In other news, be careful what news aggregator you use!! I tried and like RSS Reader. It's freeware, it's in .NET (just neat to see a useful client app in the new tech), and it does a great job parsing RSS feeds.

The problem? It uses the infamous MS Internet Control, which means it's just as vulnerable to security flaws in Internet Explorer as IE itself. That's a bad place to put your eggs, if you ask me. I've been complaining recently that end users need to be better educated about the risks of using a computer online -- this is a nasty sort of backdoor for virii. An app that looks totally unrelated to IE to the typical end user -- even one using Mozilla or Netscape for daily browsing -- can cut loose a nasty virus. Naturally, you'd hope the RSS feeding sites would be more likely to be on the up and up than your daily pr0n sites, but it's still a gaping hole that could blindside even a relatively well-informed PC user.

The answer? Well, luckily that's easy. Wrap the Mozilla ActiveX control I mentioned yesterday in a .NET wrapper (or just use COM-interop if you don't mind rewriting a bit of your .NET code), and stick a safe(er) rendering engine in your app.