顺便说一下,我声明了四个datagridcolumnstyle对象,但将它们更新为datagridtextboxcolumn,这意味着你也可以将它们更新为一个datagidboolcolumn。你当然应该知道原因啦。:-)// initialize datagrid when the form is opened. private void initializedatagrid() { // set the datagrid's datasource to a datatable dtgperiods.datasource = _perioddata.tables [accountingperioddata.accountingperiod_table];
// create a datagridtablestyle and set its mappingname is accounting_table datagridtablestyle mydtgtablestyle = new datagridtablestyle(); mydtgtablestyle.mappingname = accountingperioddata.accountingperiod_table;
// create datagridcolumnstyles, set their properties // add these datagridcollumnstyles into the datagridtablestyle defined above one by one datagridcolumnstyle periodcodestyle = new datagridtextboxcolumn(); periodcodestyle.mappingname = accountingperioddata.period_field; periodcodestyle.headertext = "會計期別"; periodcodestyle.readonly = true; mydtgtablestyle.gridcolumnstyles.add(periodcodestyle);