我有这个未绑定的datagridview在表单加载期间添加列;
这是代码;
private void loadfields()
{
dgvbulkentries.ColumnCount = 15;
dgvbulkentries.Columns[0].Name = "ID No";
dgvbulkentries.Columns[0].Width = 80;
dgvbulkentries.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dgvbulkentries.Columns[1].Name = "Surname";
dgvbulkentries.Columns[1].Width = 150;
dgvbulkentries.Columns[2].Name = "First Name";
dgvbulkentries.Columns[2].Width = 150;
dgvbulkentries.Columns[3].Name = "Name Extn";
dgvbulkentries.Columns[3].Width = 40;
dgvbulkentries.Columns[4].Name = "Middle Name";
dgvbulkentries.Columns[4].Width = 150;
dgvbulkentries.Columns[5].Name = "Course";
dgvbulkentries.Columns[5].Width = 110;
dgvbulkentries.Columns[6].Name = "Year";
dgvbulkentries.Columns[6].Width = 40;
dgvbulkentries.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dgvbulkentries.Columns[7].Name = "Street/Block";
dgvbulkentries.Columns[7].Width = 150;
dgvbulkentries.Columns[8].Name = "Subdivision";
dgvbulkentries.Columns[8].Width = 150;
dgvbulkentries.Columns[9].Name = "Barangay";
dgvbulkentries.Columns[9].Width = 150;
dgvbulkentries.Columns[10].Name = "Municipality/City";
dgvbulkentries.Columns[10].Width = 150;
dgvbulkentries.Columns[11].Name = "Province";
dgvbulkentries.Columns[11].Width = 150;
我已经为datagridview中的特定列设置了货币文本框的代码。但是问题是,当我在一个单元格中输入数字时,它根本不会改变。
这是我包含的代码;
private void dgvbulkentries_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
dgvbulkentries.Columns[14].DefaultCellStyle.Format = "n";
}
例如,当我在datagridview的特定列中输入数字时,它不会将值格式化为货币格式。我已经按照您的建议做了,但是没有用
我错过了什么?
LEATH
相关分类