Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Read Events equivalent in C#
Message
From
11/06/2021 14:03:01
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
01681125
Message ID:
01681149
Views:
60
>Hi Bill,
>
>Thanks for your reply. My code is as follows.
>
>
>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;
>using System.Data.SqlClient;
>
>namespace NTIMS
>{
>    public partial class Form1 : Form
>    {
>        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=WelkinDB;Integrated Security=True");
>        SqlCommand cmd;
>        DataTable dt;
>        SqlDataAdapter da;
>        private ListView listView1;
>        private Button button1;
>        DataSet ds;
>        static void Main()
>        {
>            new Form1();
>        }
>        public Form1()
>        {
>            InitializeComponent();
>        }
>
>        private void InitializeComponent()
>        {
>            this.listView1 = new System.Windows.Forms.ListView();
>            this.button1 = new System.Windows.Forms.Button();
>            this.SuspendLayout();
>            // 
>            // listView1
>            // 
>            this.listView1.HideSelection = false;
>            this.listView1.Location = new System.Drawing.Point(13, 12);
>            this.listView1.Name = "listView1";
>            this.listView1.Size = new System.Drawing.Size(508, 278);
>            this.listView1.TabIndex = 0;
>            this.listView1.UseCompatibleStateImageBehavior = false;
>            this.listView1.UseWaitCursor = true;
>            // 
>            // button1
>            // 
>            this.button1.Location = new System.Drawing.Point(13, 303);
>            this.button1.Name = "button1";
>            this.button1.Size = new System.Drawing.Size(112, 23);
>            this.button1.TabIndex = 1;
>            this.button1.Text = "Fill List";
>            this.button1.UseVisualStyleBackColor = true;
>            this.button1.UseWaitCursor = true;
>            this.button1.Click += new System.EventHandler(this.button1_Click);
>            // 
>            // Form1
>            // 
>            this.ClientSize = new System.Drawing.Size(533, 338);
>            this.Controls.Add(this.button1);
>            this.Controls.Add(this.listView1);
>            this.Name = "Form1";
>            this.Load += new System.EventHandler(this.Form1_Load_1);
>            this.ResumeLayout(false);
>
>        private void button1_Click(object sender, EventArgs e)
>        {
>            listView1.Items.Clear();
>            this.listView1.Columns.Add("ID",10);
>            this.listView1.Columns.Add("Surname", 70);
>            con.Open();
>            cmd = new SqlCommand("Select * from student", con);
>            da = new SqlDataAdapter(cmd);
>            ds = new DataSet();
>            da.Fill(ds, "testTable");
>            con.Close();
>            dt = ds.Tables["testTable"];
>            int i;
>            for (i=0;i<=dt.Rows.Count - 1;i++)
>            {
>                listView1.Items.Add(dt.Rows[i].ItemArray[0].ToString());
>                listView1.Items[i].SubItems.Add(dt.Rows[i].ItemArray[1].ToString());
>
>            }
>        }
>         private void Form1_Load(object sender, EventArgs e)
>        {
>            listView1.Columns.Add("ID", 20);
>            listView1.Columns.Add("Chinese Name", 40);
>            listView1.View = View.Details;
>        }
>
>        private void Form1_Load_1(object sender, EventArgs e)
>        {
>
>        }
>    }
>}
>
>
>
>Ben
>
>
>>>I created a form in C# in Visual Studio. I found that the form won't pause and I was not able test each button on the form. How do I make the form pause so that I can push on each button?
>>>
>
>
>
>
>
>>>TIA
>>>Ben
>>>
>>>
>>>>Hi Ben.
>>>>
>>>>>I'd like to ask you a question 'is there any command in C# is equivalent to VFP "Read Events"?'. Maybe you have an answer in your book but I didn't find.
>>>>
>>>>No, there isn't.
>>>>
>>>>Doug
>>
>>How are you showing the form?
>>Put the code here


I note that you have the main method in the form.
When I create a winform app, the main method is automatically created in program.cs, which instantiates and executes the form.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform