当textbox为多行时,获取它的行数:int count = this.txtMsgInfo.Lines.GetUpperBound(0);
this.textBox1.Select(this.txtMsgInfo.TextLength, 0);this.textBox1.ScrollToCaret();
DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Name"); DataRow dr = dt.NewRow(); object[] objs = { 1, "Name" }; dr.ItemArray = objs; dt.Rows.Add(dr); this.dataGridView1.DataSource = dt;