Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2007
    Messaggi
    19

    [C#] Vi prego aiutatemi - Window Form

    Ciao a tutti,

    sto veramente sbattendo la testa su un problema banalissimo!
    Ho trovato di tutto su internet e sul forum sull'argomento ma non ci credo! NON VA!

    Ho un form1 che tramite un button richiama un form2

    banalmente:

    codice:
    private void button(object sender, EventArgs e)
            {
                form2 nuovo = new form2();
                nuovo.Show();
    }
    ora nel form2 devo intercettare l'evento di chiusura del form e fare delle operazioni alla sua chiusura, ho provato di tutto compreso:

    codice:
    private void form2_Closed(object sender, System.ComponentModel.CancelEventArgs e)
            {
                //istruzioni da eseguire
            }
    non va...

    potete darmi una mano?
    dove sbaglio? ho letto di tutto e tutti riescono in questo modo... uffa...

    grazie infinite

  2. #2
    Utente di HTML.it
    Registrato dal
    Mar 2007
    Messaggi
    19
    incredibile... se invece tento di intercettare l'evento di apertura del form2 con la seguente sintassi:

    codice:
    private void form2_Load(object sender, EventArgs e)
            {
                //istruzioni
            }
    tutto funziona alla perfezione
    :master:

  3. #3
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    codice:
            private void Form2_FormClosed(object sender, FormClosedEventArgs e)
            {
                ...
            }

  4. #4
    Ma quella funzione l'hai aggiunta a mano o tramite l'editor di Windows Forms?
    Amaro C++, il gusto pieno dell'undefined behavior.

  5. #5
    Utente di HTML.it
    Registrato dal
    Mar 2007
    Messaggi
    19
    Originariamente inviato da oregon
    codice:
            private void Form2_FormClosed(object sender, FormClosedEventArgs e)
            {
                ...
            }
    niente... non va nemmeno così.. ma su MSDN c'è scritto che si fa come avevo scritto io...
    ma possibile che devo arenarmi su una cosa così banale?
    uffa

    grazie mille

  6. #6
    Utente di HTML.it
    Registrato dal
    Mar 2007
    Messaggi
    19
    Originariamente inviato da MItaly
    Ma quella funzione l'hai aggiunta a mano o tramite l'editor di Windows Forms?
    quale funzione? la closed?
    quella a mano

    però in effetti quella che intercetta l'evento Open tramite Visual studio 2005

    sarà che manca qualcosa?

    boh...

  7. #7
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Originariamente inviato da nakota
    niente... non va nemmeno così.. ma su MSDN c'è scritto che si fa come avevo scritto io...
    ma possibile che devo arenarmi su una cosa così banale?
    uffa

    grazie mille
    Guarda che cosi' va bene ... che problema hai?

  8. #8
    Utente di HTML.it
    Registrato dal
    Mar 2007
    Messaggi
    19
    Che non funziona... incredibile...


  9. #9
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Allora ... quale versione di VS usi (e framework) e il codice *completo* che stai provando adesso.

  10. #10
    Utente di HTML.it
    Registrato dal
    Mar 2007
    Messaggi
    19
    Visual Studio 2005 Pro

    program.cs

    codice:
    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    
    namespace Easy
    {
        static class Program
        {
            /// <summary>
            /// Punto di ingresso principale dell'applicazione.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new principale());
            }
            
        }
    }

    principale.cs
    codice:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace Easy
    {
        public partial class principale : Form
        {
            public principale()
            {
                InitializeComponent();
            }
    
            private void documentation_Click(object sender, EventArgs e)
            {
                try
                {
                    System.Diagnostics.Process.Start("Easy.pdf");
                }
                catch (System.IO.FileNotFoundException fnfEx)
                {
                    MessageBox.Show("Attenzione! Impossibile trovare il file della documentazione.");   
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Attenzione! Impossibile aprire il file. Necessario Adobe Reader.");
                }
                finally
                {
                    
                }
    
    
                
            }
    
            private void nuovo_EOW_Click(object sender, EventArgs e)
            {
                fase1 lafase1 = new fase1();
                //lafase1.FormClosing += new FormClosingEventHandler(lafase1_FormClosing);
                lafase1.Show(); //qui faccio partire il secondo FORM
            }
            
    
        }
    }

    fase1.cs

    codice:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace Easy
    {
        
        public partial class fase1 : Form
        {
            public fase1()
            {
                InitializeComponent();
                //principale.ActiveForm.Visible = false;
            }
    
            private void fase1_Load(object sender, EventArgs e)
            {
                MessageBox.Show("BLABLABLABLABLA", "My Application", MessageBoxButtons.YesNo); //questo funziona
    
            }
    
            private void fase1_FormClosed(object sender, FormClosedEventArgs e)
                {
                MessageBox.Show("Do you want to save changes to your text?", "My Application", MessageBoxButtons.YesNo);
                }  //QUESTO NON FUNZIONA
    
            
            /*private void fase1_Closed(object sender, System.ComponentModel.CancelEventArgs e)
            {
                MessageBox.Show("Do you want to save changes to your text?", "My Application", MessageBoxButtons.YesNo);
            }*/  
    //nemmeno questo funziona
    
    
        }
    }

    fase1.Designer.cs

    codice:
    namespace Easy
    {
        partial class fase1
        {
            /// <summary>
            /// Variabile di progettazione necessaria.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Liberare 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.components = new System.ComponentModel.Container();
                this.infolicenza = new System.Windows.Forms.GroupBox();
                this.tabControl1 = new System.Windows.Forms.TabControl();
                this.tabPage1 = new System.Windows.Forms.TabPage();
                this.tabPage2 = new System.Windows.Forms.TabPage();
                this.infocontenuto = new System.Windows.Forms.GroupBox();
                this.labuidlicenza = new System.Windows.Forms.Label();
                this.UID_Licenza = new System.Windows.Forms.TextBox();
                this.info_UID_licenza = new System.Windows.Forms.ToolTip(this.components);
                this.infolicenza.SuspendLayout();
                this.tabControl1.SuspendLayout();
                this.SuspendLayout();
                // 
                // infolicenza
                // 
                this.infolicenza.Controls.Add(this.UID_Licenza);
                this.infolicenza.Controls.Add(this.labuidlicenza);
                this.infolicenza.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.infolicenza.Location = new System.Drawing.Point(12, 33);
                this.infolicenza.Name = "infolicenza";
                this.infolicenza.Size = new System.Drawing.Size(367, 223);
                this.infolicenza.TabIndex = 0;
                this.infolicenza.TabStop = false;
                this.infolicenza.Text = "Informazioni Licenza";
                // 
                // tabControl1
                // 
                this.tabControl1.Controls.Add(this.tabPage1);
                this.tabControl1.Controls.Add(this.tabPage2);
                this.tabControl1.Location = new System.Drawing.Point(400, 33);
                this.tabControl1.Name = "tabControl1";
                this.tabControl1.SelectedIndex = 0;
                this.tabControl1.Size = new System.Drawing.Size(379, 374);
                this.tabControl1.TabIndex = 1;
                // 
                // tabPage1
                // 
                this.tabPage1.Location = new System.Drawing.Point(4, 22);
                this.tabPage1.Name = "tabPage1";
                this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
                this.tabPage1.Size = new System.Drawing.Size(371, 348);
                this.tabPage1.TabIndex = 0;
                this.tabPage1.Text = "tabPage1";
                this.tabPage1.UseVisualStyleBackColor = true;
                // 
                // tabPage2
                // 
                this.tabPage2.Location = new System.Drawing.Point(4, 22);
                this.tabPage2.Name = "tabPage2";
                this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
                this.tabPage2.Size = new System.Drawing.Size(192, 74);
                this.tabPage2.TabIndex = 1;
                this.tabPage2.Text = "tabPage2";
                this.tabPage2.UseVisualStyleBackColor = true;
                // 
                // infocontenuto
                // 
                this.infocontenuto.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.infocontenuto.Location = new System.Drawing.Point(12, 262);
                this.infocontenuto.Name = "infocontenuto";
                this.infocontenuto.Size = new System.Drawing.Size(367, 145);
                this.infocontenuto.TabIndex = 2;
                this.infocontenuto.TabStop = false;
                this.infocontenuto.Text = "Informazioni Contenuto";
                // 
                // labuidlicenza
                // 
                this.labuidlicenza.AutoSize = true;
                this.labuidlicenza.Location = new System.Drawing.Point(6, 39);
                this.labuidlicenza.Name = "labuidlicenza";
                this.labuidlicenza.Size = new System.Drawing.Size(95, 17);
                this.labuidlicenza.TabIndex = 0;
                this.labuidlicenza.Text = "UID Licenza";
                // 
                // UID_Licenza
                // 
                this.UID_Licenza.Location = new System.Drawing.Point(107, 39);
                this.UID_Licenza.Name = "UID_Licenza";
                this.UID_Licenza.Size = new System.Drawing.Size(254, 23);
                this.UID_Licenza.TabIndex = 1;
                // 
                // info_UID_licenza
                // 
                this.info_UID_licenza.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
                this.info_UID_licenza.UseAnimation = false;
                this.info_UID_licenza.Popup += new System.Windows.Forms.PopupEventHandler(this.info_UID_licenza_Popup);
                // 
                // fase1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(790, 457);
                this.Controls.Add(this.infocontenuto);
                this.Controls.Add(this.tabControl1);
                this.Controls.Add(this.infolicenza);
                this.Name = "fase1";
                this.Text = "Easy ODRL Writer - FASE1";
                this.Load += new System.EventHandler(this.fase1_Load);
                this.infolicenza.ResumeLayout(false);
                this.infolicenza.PerformLayout();
                this.tabControl1.ResumeLayout(false);
                this.ResumeLayout(false);
                //SECONDO ME C'E da AGGIUNGERE QUALCOSA QUI MA HO PROVATO UNA VALANGA DI COSE
    
            }
    
            #endregion
    
            private System.Windows.Forms.GroupBox infolicenza;
            private System.Windows.Forms.TabControl tabControl1;
            private System.Windows.Forms.TabPage tabPage1;
            private System.Windows.Forms.TabPage tabPage2;
            private System.Windows.Forms.GroupBox infocontenuto;
            private System.Windows.Forms.Label labuidlicenza;
            private System.Windows.Forms.TextBox UID_Licenza;
            private System.Windows.Forms.ToolTip info_UID_licenza;
    
    
    
    
    
        }
    }
    grazie infinite

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.