segunda-feira, 17 de dezembro de 2018

C# - Imprimindo array de string em label

IMPRIMINDO ARRAY DE STRING EM LABEL 





using System;
using System.Drawing;
using System.Windows.Forms;

namespace keypress {
    public partial class Form1 : Form {
        public System.Windows.Forms.Label label_1;
        /*============================================================*/
        public void Label_text_1 ( ) {
            label_1.Location = new Point ( 100, 50 );
            label_1.Size = new Size ( 400, 180 );
            label_1.Font = new Font ( "Times New Roman", 12F,
             System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0 );
            //Colororindo a font do label com rgb
            label_1.ForeColor = Color.FromArgb ( 0, 0, 0 );
        }
        /*============================================================*/
        public void Ini_Array ( ) {
            label_1 = new System.Windows.Forms.Label ( );
            int i, j = 0;
            string [ , ] texto = new string [ , ] {
                   {"Debaixo dumas mui formosas tamareiras,      \n"},
                   {"Estando já Berseba na escuridão.            \n"},
                   {"As aves escutando, entre as roseiras,       \n"},
                   {"Se vê andar o patriarca Abraão.             \n"},
                   {"Seu coração perante Deus está aflito,       \n"},
                   {"Pois quer que O sirvamos sem murmuração;    \n"},
                   {"E por amor pergunta ao Senhor bendito:      \n"},
                   {"O meu amado filho queres Tu, então?         \n"}};
            for ( i = 0; i < texto.Length; i++ ) {
                label_1.Text += texto [ i, j ] + " ";
            }
        }
        /*============================================================*/
        protected override void OnPaint ( PaintEventArgs e ) {
            this.Size = new System.Drawing.Size ( 600, 300 );
            this.Text = "IMPRIMINDO ARRAY EM LABEL";
            this.BackColor = Color.LightBlue;
            Graphics dc = e.Graphics;
            Pen BluePen = new Pen ( Color.Blue, 10 );
            dc.DrawRectangle ( BluePen, 5, 5, 575, 250 );
            Font myFont = new System.Drawing.Font ( "Helvetica", 14,
                FontStyle.Italic );
            Brush myBrush_1 = new SolidBrush ( System.Drawing.Color.Red );
             dc.DrawString ( "IMPRIMINDO ARRAY EM LABEL",
             myFont, myBrush_1, 160, 15 );
        }
        /*============================================================*/
        public Form1 ( ) {
            Ini_Array ( );
            Label_text_1 ( );
            this.Controls.Add ( this.label_1 );
        }
    }
    /*============================================================*/
    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 ( ) );
        }
    }
}

Nenhum comentário:

Postar um comentário