代码如下:
conn.ChangeDatabase("consume_db");
data = new DataTable();
da = new MySqlDataAdapter("SELECT * FROM consume_stock" , conn);
cb = new MySqlCommandBuilder(da);
da.Fill(data);
//得到数据源
dataGrid.DataSource = data;
DataGridTableStyle ts = new DataGridTableStyle(); //定义TableStyle
ts.MappingName = "consume_stock"; //映射表名称,重要
ts.ReadOnly = false; //整个DataGrid读写方式
DataGridTextBoxColumn tc = new DataGridTextBoxColumn(); //定义第一列用TextBox渲染
tc.HeaderText = "状态类型"; //改变列头的显示
tc.MappingName = "NAME"; //映射列的名称,重要,实际就是查询select 对因的列
tc.Alignment = HorizontalAlignment.Right; //对齐方式
tc.ReadOnly = true; //指明这一列的为只读方式
ts.PreferredColumnWidth = 1070; //指明Cell宽度
ts.PreferredRowHeight = 20; //指名Cell高度
ts.AlternatingBackColor = Color.LightGray;
ts.GridColumnStyles.Add(tc); //为ColumnStyle添加上面的TextBox
dataGrid.TableStyles.Add(ts);
没有改变:
但最后没有改变,请问是什么原因。