change datagridview cell type containing text vaue "true" text to checkbox

kay-B

I have a datagridview that has cells with text values that have "True" for one column and the next column should have a Combobox with two values to choose from (in and out)... I want to change the cell type to be a check box and cell type to Combobox... if the cell text is "true" the checkbox must be checked and if it is false or there is nothing in it, it must be unchecked if text from the direction column is in the Combobox value must be set to IN and have an extra option of out in it ... this DATA comes from a loaded XML file, this is how I load the XML file to the datagridview

public void Load(DataGridView dgv)
{             
    dgv.Refresh();
    XmlReaderxmlFile = XmlReader.Create(@"path/DGVXML.xml",newXmlReaderSettings());
    DataSet dataSet = new DataSet();
    dataSet.ReadXml(xmlFile);
    dgv.DataSource = dataSet.Tables[0];
    xmlFile.Close();              
 }

enter image description here

the datagridview must display as follows

enter image description here

kay-B

this is what iv added to the load method and worked 100%

  dgv.Refresh();
                XmlReader xmlFile = XmlReader.Create(@"/DGVXML.xml", new XmlReaderSettings());
                DataSet dataSet = new DataSet();
                dataSet.ReadXml(xmlFile);

                DataGridView grid = new DataGridView();
                var nameColumn = new DataGridViewTextBoxColumn();
                nameColumn.Name = "Device Name";
                nameColumn.HeaderText = "Device Name";
                dgv.Columns.Add(nameColumn);


                var checkColumn = new DataGridViewCheckBoxColumn();
                checkColumn.Name = "Select";
                checkColumn.HeaderText = "Select";
                dgv.Columns.Add(checkColumn);

                string IN = "IN";
                string OUT = "OUT";
                var select = new DataGridViewComboBoxColumn();
                select.HeaderText = "Direction";
                select.Name = "Direction";
                select.Items.Add(IN);
                select.Items.Add(OUT);
                dgv.Columns.Add(select);

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    string DeviceName = row[0].ToString();

                     bool Enabled = false;
                    if (row[1].ToString() != "")
                        Enabled = Convert.ToBoolean( row[1].ToString());

                    string Direction = row[2].ToString();

                    DataGridViewRow dgRow = new DataGridViewRow();
                    dgv.Rows.Add(new object[] {DeviceName, Enabled, Direction});
                }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to change text of the top left cell of a datagridview?

From Dev

Change text of a cell on dataGridView_CellFormatting

From Dev

Multiline text in DataGridView Cell

From Dev

Change color of only part of text inside a DataGridView cell

From Dev

Change textcolor of a row in a datagridview if a cell contains part of text c#

From Dev

Datagridview checkbox cell change color of button and drawline

From Dev

Change Text if checked - checkbox

From Dev

Merge DataGridView Image cell with text cell

From Dev

how to replace text with numerical vaue in excel

From Dev

Blinking Text If checkbox is checked to true

From Dev

change text box text if checkbox is checked

From Dev

Why my Checkbox change to text

From Dev

VBA Set Cell value to text containing ' not working

From Dev

Identify cell containing given text in LibreOffice Calc

From Dev

Hide row based on cell containing text

From Dev

Deactivate checkbox if a condition in a text input is true in javascript

From Dev

excel search range for specific text copy cell containing text

From Dev

If text string exist select cell containing text string

From Dev

excel search range for specific text copy cell containing text

From Dev

Associate input type checkbox to input type text

From Dev

ASP VB.NET GridView: Change Column cell text by column header name with AutogenerateColumn = True

From Dev

Find address of a cell containing a formula, using text value in the cell

From Dev

how to delete cell value if cell is containing special text

From Dev

HOW TO: Change datagridview LinkColumn Text when clicked

From Dev

Change colour of a cell based on the value in the cell and text in another cell

From Dev

Change checkbox text color when checked

From Dev

CheckBox text to change based on its IsChecked

From Dev

Change Text input value on checkbox select

From Dev

Change TextBox text and focus via CheckBox in XAML

Related Related

  1. 1

    How to change text of the top left cell of a datagridview?

  2. 2

    Change text of a cell on dataGridView_CellFormatting

  3. 3

    Multiline text in DataGridView Cell

  4. 4

    Change color of only part of text inside a DataGridView cell

  5. 5

    Change textcolor of a row in a datagridview if a cell contains part of text c#

  6. 6

    Datagridview checkbox cell change color of button and drawline

  7. 7

    Change Text if checked - checkbox

  8. 8

    Merge DataGridView Image cell with text cell

  9. 9

    how to replace text with numerical vaue in excel

  10. 10

    Blinking Text If checkbox is checked to true

  11. 11

    change text box text if checkbox is checked

  12. 12

    Why my Checkbox change to text

  13. 13

    VBA Set Cell value to text containing ' not working

  14. 14

    Identify cell containing given text in LibreOffice Calc

  15. 15

    Hide row based on cell containing text

  16. 16

    Deactivate checkbox if a condition in a text input is true in javascript

  17. 17

    excel search range for specific text copy cell containing text

  18. 18

    If text string exist select cell containing text string

  19. 19

    excel search range for specific text copy cell containing text

  20. 20

    Associate input type checkbox to input type text

  21. 21

    ASP VB.NET GridView: Change Column cell text by column header name with AutogenerateColumn = True

  22. 22

    Find address of a cell containing a formula, using text value in the cell

  23. 23

    how to delete cell value if cell is containing special text

  24. 24

    HOW TO: Change datagridview LinkColumn Text when clicked

  25. 25

    Change colour of a cell based on the value in the cell and text in another cell

  26. 26

    Change checkbox text color when checked

  27. 27

    CheckBox text to change based on its IsChecked

  28. 28

    Change Text input value on checkbox select

  29. 29

    Change TextBox text and focus via CheckBox in XAML

HotTag

Archive