How to do the ListBox analog in VS 2015



  • How to do it VS 2015 equivalent ListBoxbut with the possibility of user editing data, that is, in fact, a table consisting of textbox?

    Use yourself textbox I can't, because I can always ask for different numbers, but listbox It is not appropriate that the price list be auto-edited and sometimes edited in the process of use.



  • Table consisting of textbox

    If there are several columns in the table, the dataGridView can be used in WinForms, which can define the type of ejectable cells.

    For example, in the cells, textBox should use DataGridViewTextBoxColumn.

    class Data {
        public string Value { get; set; }
    }
    

    var f = new Form();
    var g = new DataGridView() {
    Parent = f,
    Dock = DockStyle.Fill,
    AutoGenerateColumns = false,
    AllowUserToAddRows = false,
    AllowUserToDeleteRows = false
    };
    g.Columns.Add(new DataGridViewTextBoxColumn() {
    HeaderText = "value",
    DataPropertyName="Value"
    });
    var l = new BindingList<Data>();
    for (var i = 0; i < 5; i++)
    l.Add(new Data() { Value = "v"+i });
    g.DataSource = l;
    f.ShowDialog();

    Data.Value values are published in DataGridView and can be edited and changes transferred back to Data.Value.

    If a column is to be added, Data should add a characteristic and add another column to DataGridView.Columns.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2