第一方法用于对你原有数据进行一些数据格式列的添加,以及绑定
那么在第一个方法中你可以用这种列添加的方式,也可以用变量来暂时存储临时数据,例如在点击事件中将这个值取出来保存在一个全局变量中,然后在离开事件中再将这个变量的值给这个cell,都可以
第二个和第三个方法是DataGridView的事件,用于你的双击和离开后的显示值转换
不明白话,再HI我吧
private void button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable()
DataColumn dcId = new DataColumn("id")
DataColumn dcValue = new DataColumn("value")
dt.Columns.Add(dcId)
dt.Columns.Add(dcValue)
DataRow dr = dt.NewRow()
dr[0] = 1
dr[1] = 123.456
dt.Rows.Add(dr)
DataColumn tempValue = new DataColumn("tempTypeValue")
dt.Columns.Add(tempValue)
DataColumn typeValue = new DataColumn("typeValue")
dt.Columns.Add(typeValue)
foreach (DataRow dritem in dt.Rows)
{
dritem["tempTypeValue"] = float.Parse(dritem["value"].ToString()).ToString("F2")
dritem["typeValue"] = float.Parse(dritem["value"].ToString()).ToString("F2")
}
dataGridView1.DataSource = dt
foreach (DataGridViewColumn dgvc in dataGridView1.Columns)
{
dgvc.Visible = dgvc.Name == "tempTypeValue" || dgvc.Name == "value" ? false : true
}
}
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == dataGridView1.Columns["typeValue"].Index)
{
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = dataGridView1.Rows[e.RowIndex].Cells["value"].Value
}
}
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == dataGridView1.Columns["typeValue"].Index)
{
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = dataGridView1.Rows[e.RowIndex].Cells["tempTypeValue"].Value
}
}
。Lv水桶包一直是十分有名的网红包。这整个系列的水桶包都很受欢迎,百搭又耐用,但是很多人买回家后不知道怎么调整它的肩带。下面我们来看看lv水桶包调肩带到底要怎么做欢迎分享,转载请注明来源:内存溢出
评论列表(0条)