如何在复选框中显示datagridview列 [英] How to display a datagridview column in checkbox

查看:100
本文介绍了如何在复选框中显示datagridview列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个问题我想点击datagrid视图中的一行并在textbox combobox datetime picker中显示内容以及复选框但问题是我有一个包含的框两个值是NN是O如果我的意思是检查复选框= O否则= N

我不知道我说的很好我的问题我希望有人理解我

这是我的剧本,

提前谢谢



我尝试了什么:



i尝试

Hello,
I have a problem I want to click on a row in datagrid view and display the content in textbox combobox datetime picker as well as checkbox but the problem is I have a box that contains two values ​​be N N is O If I mean Check the checkbox = O otherwise = N
I do not know is what I described well my problem I hope that someone understands me
Here is my script,
thank you in advance

What I have tried:

i tried

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string cocher = null;
            if (values.username.Equals("admin"))
            {
                if (checkBox1.Checked == true)
                {
                    cocher = "O";
                }
                else
                {
                    cocher = "N";
                }
                if (e.RowIndex >= 0)
                {
                    DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
                    textBox2.Text = row.Cells["Id_marche"].Value.ToString();
                    comboBox1.SelectedItem = row.Cells["Libelle_site"].Value.ToString();
                    comboBox3.SelectedItem = row.Cells["Libelle_fournisseur"].Value.ToString();
                    textBox1.Text = row.Cells["Num_marche"].Value.ToString();
                    dateTimePicker1.Value = DateTime.Parse(row.Cells["Date_demarrage"].Value.ToString());
                    dateTimePicker1.Value = DateTime.Parse(row.Cells["Date_fin"].Value.ToString());
                    textBox3.Text = row.Cells["Libelle_marche"].Value.ToString();
                    textBox4.Text = row.Cells["Description"].Value.ToString();
                    comboBox2.Text = row.Cells["Type_marche"].Value.ToString();
                    textBox5.Text = row.Cells["Montant"].Value.ToString();
                    textBox6.Text = row.Cells["Devise"].Value.ToString();
                }
            }
        }

推荐答案

这是一个包含很多答案的Google搜索。选择最适合您需求的那个:



winform datagridview复选框列 - Google搜索 [ ^ ]
Here is a Google Search with many answers for you. Pick the one that best suits your needs:

winform datagridview checkbox column - Google Search[^]


这篇关于如何在复选框中显示datagridview列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆