problem adding another Tab event using lostfocus in form

csharp Nepal
  • 12 years ago

    hey this is the coding i have done to add an event at the last textbox,

    i want to reach out to the last newly created textbox so that this event can be repeated again and then i can add the last textboxes info....please help!!

     

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Data.SqlClient;

    using System.Windows.Forms;

    namespace ezeeeshop

    {

    public partial class Form10 : Form

    {

    SqlConnection con = new SqlConnection(@"server=514c66c4338e42b\sqlexpress;initial catalog=new;integrated security=SSPI");public Form10()

    {

    InitializeComponent();

    }

    private void a(object sender, EventArgs e)

    {

    ComboBox c = new ComboBox();c.Location = new Point(74,327);

    c.DataSource = salesBindingSource3;

    c.DisplayMember = "product_name";

    c.Size=new Size( 197,24);

    Controls.Add(c);

    TextBox t = new TextBox();

    t.Location = new Point(302, 327);

    //t.DataSource = salesBindingSource3;

    //t.DisplayMember = "product_name";

    //t.Size = new Size(197, 24);

    Controls.Add(t);

    TextBox t1 = new TextBox();t1.Location = new Point(436, 327);

    Controls.Add(t1);

    TextBox t2 = new TextBox();

    t2.Location = new Point(566, 327);

    Controls.Add(t2);

    TextBox t3 = new TextBox();t3.Location = new Point(686, 327);

    Controls.Add(t3);

    TextBox t4 = new TextBox();

    t4.Location = new Point(814, 327);

    Controls.Add(t4);

     

    }

     

    private void Form10_Load(object sender, EventArgs e)

    {

    // TODO: This line of code loads data into the 'newDataSet2.sales' table. You can move, or remove it, as needed.

    this.salesTableAdapter1.Fill(this.newDataSet2.sales);

    // TODO: This line of code loads data into the 'newDataSet1.sales' table. You can move, or remove it, as needed.

    this.salesTableAdapter.Fill(this.newDataSet1.sales);

     

    textBox6.LostFocus +=
    new System.EventHandler(this.a);string j = DateTime.Today.Date.ToString();

    label2.Text = j;

    }

    private void label2_Click(object sender, EventArgs e)

    {

     

    }

    private void textBox4_TextChanged(object sender, EventArgs e)

    {

    }

    private void textBox7_TextChanged(object sender, EventArgs e)

    {

    }

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

    {

    con.Open();

    string s = "select * from sales where product_name='"+comboBox1.Text+"'";

    SqlDataAdapter da = new SqlDataAdapter(s, con);

    DataSet ds = new DataSet();

    da.Fill(ds,"sales");

    try

    {

    textBox2.Text = ds.Tables[0].Rows[0][1].ToString();

    textBox4.Text = ds.Tables[0].Rows[0][3].ToString();

    }

    catch

    { }

    con.Close();

    }

    private void textBox5_TextChanged(object sender, EventArgs e)

    {

    int a = int.Parse(textBox3.Text);

    int b = int.Parse(textBox4.Text);

    int c = int.Parse(textBox5.Text);int d = a * b - c;

     

    textBox6.Text = d.ToString();

    }

    private void textBox6_TextChanged(object sender, EventArgs e)

    {

    }

    private void textBox2_TextChanged(object sender, EventArgs e)

    {

    }

    }

    }

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The generation of random numbers is too important to be left to chance.” - Robert R. Coveyou