Saturday 15 August 2015

c# - about having rows with different datatype to be shown in datagridview in application form -


Hi guys, how do you create a gridview where the first line has a text and the second line has a blanket-box?

I tried the code below, but it presents the combobox control in a simple text that says total item of kickboxes.

  // Create Columns DataColumn Column 1 = New Data Column (); Column 1 Caption = "attribute"; Column1.ColumnName = "attribute"; Call1.DataType = typeof (string); Data column column 2 = new data column (); Column2.Caption = "value"; Column2.ColumnName = "value"; Column 2 Datatype = typef (object); Datatable dt = new datatable (); Dt.Columns.Add (column1); Dt.Columns.Add (column2); // Population Datacore line 1 = DT. NewRow (); Row1.ItemArray = New Object [] {"Id", "1"}; Datarao row2 = DT. NRO (); Row2.ItemArray = New Object [] {"Name", "Vincent"}; Combo box cbox = new combo box (); Cbox.DropDownStyle = ComboBoxStyle.DropDownList; Cbox.Items.AddRange (new object [] {1,2,3,4,5}); Detroor line 3 = DT. NRO (); Row3.ItemArray = New Object [] {"Brother Sister's Number", cbox}; Detroe line 4 = DT. NRO (); Row4.ItemArray = New Object [] {"Age", "21"}; Dt.Rows.Add (ROW1); Dt.Rows.Add (line2); Dt.Rows.Add (row3); Dt.Rows.Add (row4); // Grid in DataGradeView data data View1.DataSource = dt; DataGridView1.Refresh ();   

Is there any other way? I can separate the combobox from the Datagridview control like a cell (combobox), when it is clicked, it will have a dialog box popup with the combo box (the second form), but it will make the user inconvenient.

The user needs this type of functionality and should be in the DataGrade view (the field is associated with the XML (dynamic field)). The content of the dropdown is just a sample, it will be given different values, such as when entering the gender, there will be men and women items instead.

Thanks in advance. Try adding text boxes and combobox in the same column but <

dataGridView1.ColumnCount = 2; // 2 Text Box Columns Create DataGrid View 1. Columns [0] .HeaderText = "name"; DataGridView1.Column [0] .Width = 350; DataGridView1.Column [1] .HeaderText = "Value"; DataGridView1.Column [1] .Width = 150; Data GridViewerver Hetrov = New Data Gridview (); Data GridViewtextboxKeyel Textbox = New DataGridWithTaxxbox (); TextBoxCell.Value = "Turn on the base"; Data Gridview Colombo Boxcabel Combochle = NewData Grid ViewCuboboxCail (); ComboCell.Items.Add ("Chip Transaction"); ComboCell.Items.Add ("win / loss"); Heterow0.Cells.Add (textBoxCell); Heterow0.Cells.Add (comboCell); DataGridView1.Rows.Add (heterow0); // The first cell in this row has a combo

No comments:

Post a Comment