The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C#


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags: , , ,

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 08-05-2007, 11:57 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Icon13 Help with C# GUI and ActionListener

Here's my current .cs code:

PHP Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DChat
{
    
public partial class DChat Form
    
{
        
public DChat()
        {
            
InitializeComponent();
        }

        
private void ServerTextBox(object senderEventArgs e)
        {

        }

        
private void SendButton(object senderEventArgs e)
        {
           
        }

        
private void ServerTextField(object senderEventArgs e)
        {

        }

        
public static void main()
        {
            new 
DChat();
        }
    }

It seems like much easier to design GUI in C# than Java lol.. well, that's probably I didn't use any software designer for it, but yeah, I'm trying to create a networking application with C#. I'm still not sure what to use to add ActionListener (in java) for C#...

I got this error for my current code:
Error 1 Program 'C:\Documents and Settings\HelloWorld\My Documents\Visual Studio 2005\Projects\DChat\DChat\obj\Debug\DChat.exe' does not contain a static 'Main' method suitable for an entry point DChat

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 08-06-2007, 08:21 AM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 416
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
I don't understand your question. Your code is interesting though as new DChat is called within DChat itself, thereby creating a recursive call? How did you create this? What kind of app did you choose when you created it?

I'm rather new to C# too.

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #3 (permalink)  
Old 08-06-2007, 11:02 AM
Bench Bench is offline
Full Programmer
Join Date: Jul 2007
Location: UK
Posts: 109
iTrader: (0)
Bench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished road
Quote:
Originally Posted by TeraTask View Post
I don't understand your question. Your code is interesting though as new DChat is called within DChat itself, thereby creating a recursive call? How did you create this? What kind of app did you choose when you created it?

I'm rather new to C# too.
I don't do much C# but..

a static function inside a class doesn't belong to objects created of that class, but to the class itself (Where a class is like a cookie-cutter for objects. Many instances/objects of the class can exist, but the class itself only exists once).

in a way, a static function is like a global function, which exists once and only once for the lifetime of the entire program.

In fact, a class can create objects of itself at any time. Although a constructor should be careful in creating objects of its own class, since there is the potential for an infinite loop there (an object's constructor calling an object's constructor calling an object's constructor.. etc)


As to the original error message, I think C# does an unusual thing of capitalising the first letter of Main() - your main() is a lowercase 'm' (as per C/C++/Java)

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by Bench : 08-06-2007 at 11:07 AM.
Reply With Quote
The Following User Says Thank You to Bench For This Useful Post:
TeraTask (08-06-2007)
  #4 (permalink)  
Old 08-06-2007, 05:48 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
I don't understand your question. Your code is interesting though as new DChat is called within DChat itself, thereby creating a recursive call?
No, this is not a recursive call. I'm instantiating the class of DChat within my main method, so it's basically calling this class. Recursive is a method calling itself, however, this is a method that's calling a class named DChat.

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #5 (permalink)  
Old 08-06-2007, 11:33 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
LOL, this is really dumb.. I had to do this to get the GUI works

PHP Code:
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace DChat
{
    static class 
Program
    
{
        
/// <summary>
        /// The main entry point for the application.
        /// </summary>
        
[STAThread]
        static 
void Main()
        {
            
Application.EnableVisualStyles();
            
Application.SetCompatibleTextRenderingDefault(false);
            
Application.Run(new Form1());
        }
    }

I guess I deleted the Program.cs lol...

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #6 (permalink)  
Old 08-07-2007, 10:24 PM
Forrest
Posts: n/a
And for the record, creating a new instance of a form class is only half the battle. You can create and cache instances for later use ... but if you don't call Form.Show() or Form.ShowDialog() ... which Application.Run() does ... nothing happens.

In theory just instantiating a new form would allocate some memory and call its constructor, but I think the compiler will recognize that you're never using the object, and optimize it out of the final code.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #7 (permalink)  
Old 08-09-2007, 12:08 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
And for the record, creating a new instance of a form class is only half the battle. You can create and cache instances for later use ... but if you don't call Form.Show() or Form.ShowDialog() ... which Application.Run() does ... nothing happens.
yeah, it's really similar with Java where you have to setVisible(true) lol...
But I'm not sure where should I put that line that you're talking about here? I just instantiate the instance of the Form1 on my current code, where do you see the Form.Show() ???

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 04:41 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50