Exemple #1
0
        private void Frmsccj_Load(object sender, System.EventArgs e)
        {
            try
            {
                //初始化
                DataTable myTb = new DataTable();

                for (int i = 0; i <= this.myDataGrid1.TableStyles[0].GridColumnStyles.Count - 1; i++)
                {
                    if (this.myDataGrid1.TableStyles[0].GridColumnStyles[i].GetType().ToString() == "System.Windows.Forms.DataGridBoolColumn")
                    {
                        myTb.Columns.Add(this.myDataGrid1.TableStyles[0].GridColumnStyles[i].HeaderText, Type.GetType("System.Int16"));
                    }
                    else
                    {
                        myTb.Columns.Add(this.myDataGrid1.TableStyles[0].GridColumnStyles[i].HeaderText, Type.GetType("System.String"));
                    }

                    this.myDataGrid1.TableStyles[0].GridColumnStyles[i].MappingName = this.myDataGrid1.TableStyles[0].GridColumnStyles[i].HeaderText;
                    this.myDataGrid1.TableStyles[0].GridColumnStyles[i].NullText    = "";
                }

                DataRow row = myTb.NewRow();
                row["序号"] = "1";
                myTb.Rows.Add(row);

                this.myDataGrid1.DataSource = myTb;
                this.myDataGrid1.TableStyles[0].MappingName = "Tb";
                this.AddData("");

                Yp.Addcmbtlfl(cmbyplx, InstanceForm.BDatabase);
                Addcmbjxdl(cmbjxdl, InstanceForm.BDatabase);
            }
            catch (System.Exception err)
            {
                MessageBox.Show("发生错误" + err.Message);
            }
        }