View Full Version : AS3 to Visual C#.NET - some difficulty.
Fingers
12-25-2006, 12:42 AM
The last few days I've been trying to get started learning C#.Net. I'm not thrilled about it, but I think it's probably a good idea to know at least one other language besides AS3, which is my main focus.
Anyway, I found a couple of e-books and videos that cover the basics of C# and they've been helpful. One problem these books and videos all share, however, is the approach they take to creating windows form applications. I'm just finding it too visual. I'm supposed to manually drag and drop components onto a form and place little snippets of code on each instance--which means that if I've got a dozen buttons on my form, I've got a dozen little code snippets to keep track of. It feels like a big step backwards compared to what I'm used to. With AS3 I am used to creating objects and placing them on the stage using pure code. One C# video breezes through a 'longhand' version of creating a simple window with a couple of components, no drag and drop, but it goes by so fast it's impossible to follow. Just from what I can see, though, it's a lot like what I had been expecting.
I hope it isn't totally against the rules of this forum to ask a C# question. Perhaps someone will understand my problem and point me to the right C# book, website, video; or, if it is permitted, wouldn't mind posting a small code sample of a window with a button and textfield being created in 'longhand' -- when the button is clicked a message appears in the textfield. :)
Fingers
Fingers
12-25-2006, 11:08 PM
How in blazes has anyone ever learned to write serious, real world programs for windows using C#, when all the sites and books just cover drag and drop with code snippets?
Dazzer
12-26-2006, 12:54 AM
amen
the realm of C has always been out of bounds to me. hehe I did manage to learn how to do console apps, but w32 apps are still out of the question.
I'm hoping though learning AS3, I should be able to learn C without much trouble now...
Fingers
12-26-2006, 01:56 AM
Lol. It isn't just me then. :) Seriously, it's like AS3 was made by Santa, C# by the grinch. Hey, wanna make a console program to sort the pennies of your wholesale sock business, count the number of drips from a leaking faucet? C# is for you! :)
Fingers
Dazzer
12-26-2006, 01:59 AM
yay...
I'm currently downloading XNA from M$. See how that goes.
edit: Seems like I'll need Visual C# Express! yayhey...
edit: bah humbug i don't have pixel shader support - cries -
puppy
12-26-2006, 04:14 AM
well first of all in visual studio (thing you seem to be talking about) there is such thing as code view (http://www.microsoft.com/mspress/books/sampchap/6714/0735619271-21.gif). If you expand that region called "Web Form Designer generated code", you will see that all that your drag-and-dropping does is that it creates good old boring code. You might as well wrote all that code yourself, and it would work the same way, but reasonably used drag-and-drop thing is huge time saver.
puppy
12-26-2006, 04:21 AM
On the second note, the only thing I would ever need to work with microsoft stuff is MSDN Library (http://msdn.microsoft.com/library/default.asp). This thing is integrated with visual studio help system, and takes about 3 CDs to store. That is enough information to answer any imaginable question, includinig numerous pure-code examples and in-depth insights on hardcore C# coding.
Dazzer
12-26-2006, 04:22 AM
true that...
Back to the good ol days of Visual Basic 6... I might actually be able to do something with VC# lol
Fingers
12-27-2006, 01:13 AM
Thanks, Puppy. Actually, until about a half hour ago I wasn't using Visual Studio but Borland's Turbo Explorer, so that might have been part of the problem. While I am still somewhat confused by the auto-generated code, the Visual Studio help system is better and I have also tracked down an ebook (http://www.programmersheaven.com/2/CSharpBook) that does not skimp on writing windows apps. So hopefully I'll get by now. :)
Dazzer, are you liking XNA? You will be learning C# then also, if I understand correctly how that works. :) Edit: What do you need for pixel shader support, a new gfx card?
Fingers
kirupa
12-27-2006, 03:03 AM
The tricky part with writing WinForms apps using pure code is getting the layout just right. Once you get your mind around the various layout styles and which one works for you, the rest is just using syntax like Button newButton = new Button(...) for having the various GUI elements display where you want them to.
For example, the following will place a button with the text "hello world" into a split container's left panel:
Button foo = new Button();
foo.Text = "hello world";
foo.Parent = splitContainer1.Panel1;
The Visual Studio 2005 AutoComplete is great for learning the syntax, so by just typing foo., you will be able to access all of the various properties you can set or get from your Button object.
Though, with the exception of populating a List control or something similar with other components, I prefer using the GUI mode for designing the interface.
:)
Dazzer
12-27-2006, 12:59 PM
C# is looking very atrractive, since i actually understand most of it (its similar to As3 in many ways)
Yes I would need a new gfx card... mine is over 5 years old. - frowns - what a bummer...
Fingers
12-27-2006, 09:19 PM
Kirupa, thanks for the reply and a many hearty thanks for your site. It is the best! :)
Ok, now I understand better how it works and I am sure that for countless situations, dragging and dropping and using the auto-generated code is a good option. On the other hand, one thing that has fascinated me since I began learning AS3 is being able to create bunches of components at once using for loops and such, with the number, placement, and values of those components determined by user input, or XML. Perhaps it's premature to worry about it. but I can't help thinking about how I will do this sort of thing with C#. The code is very economical in AS3. :)
I'm in the same boat as you, Dazzer, my card dates back almost to the last century. :)
Fingers
Dazzer
12-27-2006, 09:26 PM
I used to be able to do that in VB6... lol
You need to indicate that the component is part of a component array, and thus can be duplicated. Something like that... its been too long hehe
Fingers
12-28-2006, 12:13 AM
I wish the Kirupa forum included a C# section. There's been the occassional C# tutorial; how about a dedicated place to talk about it? .:)
Anyway, here's a page I found with an example (http://www.artisticode.com/Downloads/154.aspx) of some textboxes created in a for loop. Everything makes sense to me more or less, until this line...
TextBoxesHere.Controls.Add(new LiteralControl("<br>"));
Fingers
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.