Jump to content

try to learn c#


faustf
 Share

Recommended Posts

hi guys i try to learn a c# ,i have a little question ,  i want create a  form and after create it , i want do somthing like m.... read a file text for insert a text in a listbox, in autoit i set the instruction afte 

GUISetState(@SW_SHOW)

but in c# ??

i tryed tu insert code in

private void Form1_Load(object sender, EventArgs e)

but  do somthing  before appear  the form gui

anyone can give me some idea?? thankz

 

Link to comment
Share on other sites

i try to use in blanck form , i created new project win form ,and choice  4.8 .net framework  but  for me not run the microsoft code , maybe  do some worng

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private void Form1_Shown(Object sender, EventArgs e)
        {

            MessageBox.Show("You are in the Form.Shown event.");
        }
    }
}

appear the form but not a messageebox  after show

o_O

Link to comment
Share on other sites

A bit googling would help….

 

Place

            this.Shown += new System.EventHandler(this.Form1_Shown);

after

           this.Load += new System.EventHandler(this.Form1_Load);
 

in 'Form1.Designer.cs'

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

ok i google one night , but google explain me a delegate + events o_O0

so i tryed to insert  your code inside form1.DEsigner.cs . but  for me not  work (probably i do wrong somthing )

namespace WindowsFormsApp2
{
    partial class Form1
    {
        /// <summary>
        /// Variabile di progettazione necessaria.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Pulire le risorse in uso.
        /// </summary>
        /// <param name="disposing">ha valore true se le risorse gestite devono essere eliminate, false in caso contrario.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Codice generato da Progettazione Windows Form

        /// <summary>
        /// Metodo necessario per il supporto della finestra di progettazione. Non modificare
        /// il contenuto del metodo con l'editor di codice.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(592, 237);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Shown += new System.EventHandler(this.Form1_Shown);
            this.Load += new System.EventHandler(this.Form1_Load);

            this.ResumeLayout(false);

        }

        #endregion
    }
}

thhankz again

Link to comment
Share on other sites

that's not right. you misspelled object... lol i made this with VS 2019 Pro. works great. This is the designer code, not program code. The Program.cs file is listed below.

using System.Windows.Forms;

namespace WindowsFormsApp1
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(800, 450);
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.Shown += new System.EventHandler(this.Form1_Shown);
        }
        #endregion

        private void Form1_Load(object sender, System.EventArgs e)
        {
            MessageBox.Show("You are in the Form.Load event.");
        }
        private void Form1_Shown(object sender, System.EventArgs e)
        {
            MessageBox.Show("You are in the Form.Shown event.");
        }

    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    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());
        }
    }
}

Also, learn WPF and move to that, don't waste lots of time with WinForms.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

one more thing, how did you ever get it to compile? if you want help from me in future, post your code and give me error messages that are generated by the compiler. i use msbuild or visual studio--which uses msbuild, you can easily output to log files and paste results. if you continue your behavior you won't receive help from me any more. it shows you lack consideration from those you wish to elicit some help, and that bothers me a great deal.

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

2 hours ago, Earthshine said:

one more thing, how did you ever get it to compile? if you want help from me in future, post your code and give me error messages that are generated by the compiler. i use msbuild or visual studio--which uses msbuild, you can easily output to log files and paste results. if you continue your behavior you won't receive help from me any more. it shows you lack consideration from those you wish to elicit some help, and that bothers me a great deal.

sorry  i use visual studio comunity edition 2019 , and for me c# is  very new ,also visual studio , i try  to learn by my self , but for the moment is very difficult for me , but is very interesting to learn . next time sure i past all code , sorry , now i go to study  the difference to WPS (you suggest) to winform
 

2 hours ago, Jos said:

, for the record...  We will not allow this forum to become an "fausrf dumps all c# questions like he did with au3"! 

When you need real support learning c#, you will go somewhere where that is much more appropriate.

Agreed?

Jos 

i love Jos, thankz  again for your patience , if you notice i rise less , in au3 forum , i try to grow up my self .

thankz again at all for help

Link to comment
Share on other sites

  • Moderators
12 minutes ago, faustf said:

i love Jos, thankz  again for your patience , if you notice i rise less , in au3 forum , i try to grow up my self .

I guess I do not understand why you're even attempting to learn c#. 😕

 Most people who join this forum follow a pretty linear path of progression: after 6 months to a year of asking questions they reach a level of knowledge and experience that allows them to begin contributing by answering more than they ask. You, after 9 full years on this forum, are not only still asking - you're still asking basic questions (one of your most recent was simply having to be told you had unbalanced parentheses). 

Why - with the difficulty you seem to have taking on even the simplest tasks in AutoIt - are you trying to master a language that is magnitudes more difficult? Why not master one before you try to move on?

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

You will definitely find no argument from anyone here on that topic. Whether that is a good thing or not is a different story.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...