我有一个DataGridView,我正在填充如下所示。此DataGridView有7列,其中第1个,第4个&第6列分别将解除绑定,其余将绑定columns.Now我的要求是如何使用c#winforms显示绑定的DataGridView中的未绑定列
1]在列[0],我想显示一个自动增量整数值,如“序列号” 1,2,3 ..... n
2]在[4]列,我想显示图像列表中的图标/图像。
3]在列[6],我想说明的一个按钮控件
try
{
using (FbConnection conLLV = new FbConnection(connectionString))
{
conLLV.Open();
using (FbCommand cmdLLV = new FbCommand(sqlQryLLV, conLLV))
{
cmdLLV.Parameters.Add("@t_id", FbDbType.Integer).Value = tid;
cmdLLV.Parameters.Add("@mem_id", FbDbType.Integer).Value = mid;
cmdLLV.CommandType = CommandType.Text;
using (FbDataAdapter daLLV = new FbDataAdapter(cmdLLV))
{
using (DataTable dtLLV = new DataTable())
{
daLLV.Fill(dtLLV);
dgSSW.AutoGenerateColumns = false;
dgSSW.ColumnCount = 7;
//At Column[0] ->a Serial No column
dgSSW.Columns[1].Name = "subsec_name";
dgSSW.Columns[1].HeaderText = "Sub Section Name";
dgSSW.Columns[1].DataPropertyName = "subsec_name";
dgSSW.Columns[2].Name = "rt_correct_ans";
dgSSW.Columns[2].HeaderText = "Correct Answer";
dgSSW.Columns[2].DataPropertyName = "rt_correct_ans";
dgSSW.Columns[3].Name = "rt_your_ans";
dgSSW.Columns[3].HeaderText = "Your Answer";
dgSSW.Columns[3].DataPropertyName = "rt_your_ans";
//At Column[4] ->an Image column
dgSSW.Columns[5].Name = "q_r_difficulty";
dgSSW.Columns[5].HeaderText = "Difficulty Level";
dgSSW.Columns[5].DataPropertyName = "q_r_difficulty";
//At Column[6] ->a column having a Button control
dgSSW.DataSource = dtLLV;
}//data table closed and disposed here
}// data adapter closed and disposed up here
}// command disposed here
}//connection closed and disposed here
}
catch (FbException ex)
{
MessageBox.Show("LLV--" + ex.Message);
}
我怎样才能达到我的要求,请告知使用codes.I已经搜查了互联网,但给出的解决方案不符合我的要求。
之后哇!没有评论我的问题呢。 –