用TextBox绑定网格

//矩形帮定cb与网格方法
        public void f1(object sender, EventArgs e)
        {
            this.comboBox1.Text = dataGridView1.CurrentCell.Value.ToString();
            Rectangle R = dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex, false);
            this.comboBox1.SetBounds(R.X + this.gb_Ygxxb.Location.X + dataGridView1.Location.X, R.Y + this.gb_Ygxxb.Location.Y + dataGridView1.Location.Y, R.Width, R.Height);
            this.comboBox1.Visible = true;
        }
        //矩形帮定文本框与网格方法
        public void f2(object sender, EventArgs e)
        {
            this.textBox1.Text = dataGridView1.CurrentCell.Value.ToString();
            Rectangle R = dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex, false);
            this.textBox1.SetBounds(R.X + this.gb_Ygxxb.Location.X + dataGridView1.Location.X, R.Y + this.gb_Ygxxb.Location.Y + dataGridView1.Location.Y, R.Width, R.Height);
            this.textBox1.Visible = true;
        }
        //矩形帮定时间文本框与网格方法
        public void f3(object sender, EventArgs e)
        {
            this.dateTimePicker1.Text = dataGridView1.CurrentCell.Value.ToString();
            Rectangle R = dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex, false);
            this.dateTimePicker1.SetBounds(R.X + this.gb_Ygxxb.Location.X + dataGridView1.Location.X, R.Y + this.gb_Ygxxb.Location.Y + dataGridView1.Location.Y, R.Width, R.Height);
            this.dateTimePicker1.Visible = true;
        }

posted on 2008-09-02 00:26  VictorShan  阅读(420)  评论(0)    收藏  举报

导航