none
Problems with DataGrid in WPF RRS feed

  • Pergunta

  • Hello friends,


    Well, I'm beginning to study about the use of WPF ... I program in VB for some time. NET, and I'm having some difficulty with the WPF, specifically on the DataGrid.


    In VB. NET I created a DataGridView with six rows and seven columns. The datagridview is not associated with any database ... is more to resemble a mini table as Excel, where you can enter information.

    In WPF I manually insert the seven columns, and I inserted the six lines with this code:

    DataGrid1.Items.Add (0)
    DataGrid1.Items.Add (1)
    DataGrid1.Items.Add (2)
    DataGrid1.Items.Add (3)
    DataGrid1.Items.Add (4)
    DataGrid1.Items.Add (5)
    DataGrid1.Items.Add (6)


    By running the program, the data grid is filled with 7 columns and 6 rows.

    But when I select a cell and try to enter a value, the program displays the following error "'EditItem' is not allowed for this view.. "

    Well, I wish someone would give me some tips on how to create a table with the DataGrid in WPF, with six rows and seven columns, in which one can enter values ​​in cells. No need to save these values ​​entered into any database.

    I believe that should not be so difficult. But the DataGrid seems to be quite different from the DataGridView, which I've mastered fairly.

    Grateful for the help
    sexta-feira, 13 de maio de 2011 00:50

Respostas

Todas as Respostas

  • Hello friends,


    Well, I'm beginning to study about the use of WPF ... I program in VB for some time. NET, and I'm having some difficulty with the WPF, specifically on the DataGrid.


    In VB. NET I created a DataGridView with six rows and seven columns. The datagridview is not associated with any database ... is more to resemble a mini table as Excel, where you can enter information.

    In WPF I manually insert the seven columns, and I inserted the six lines with this code:

    DataGrid1.Items.Add (0)
    DataGrid1.Items.Add (1)
    DataGrid1.Items.Add (2)
    DataGrid1.Items.Add (3)
    DataGrid1.Items.Add (4)
    DataGrid1.Items.Add (5)
    DataGrid1.Items.Add (6)


    By running the program, the data grid is filled with 7 columns and 6 rows.

    But when I select a cell and try to enter a value, the program displays the following error "'EditItem' is not allowed for this view.. "

    Well, I wish someone would give me some tips on how to create a table with the DataGrid in WPF, with six rows and seven columns, in which one can enter values ​​in cells. No need to save these values ​​entered into any database.

    I believe that should not be so difficult. But the DataGrid seems to be quite different from the DataGridView, which I've mastered fairly.

    Grateful for the help
    sexta-feira, 13 de maio de 2011 00:49
  • Prezado,

    Por favor, pedimos para que sejam postadas somente questões em português nos fóruns da MSDN PT-BR...

    Obrigado pelo apoio...


    André Alves de Lima
    Microsoft MVP - Client App Dev
    Visite o meu site: http://www.andrealveslima.com.br
    Me siga no Twitter: @andrealveslima
    sexta-feira, 13 de maio de 2011 14:16
    Moderador
  • Opa, desculpa pelo engano

    pensei que estivesse postando no fórum dos EUA.

     

    Valeu.

    sexta-feira, 13 de maio de 2011 20:50
  • Segue como fazer a manipulação das propriedades de uma DataGrid no WPF:

        private void editDataGrid()
        {
          //Adicionando Colunas
          for (int i = 0; i < 7; i++)
          {
            dataGrid1.Columns.Add(new DataGridTextColumn { Header ="Coluna:"+i });
            
            //Adicionando Linhas
            dataGrid1.Items.Add(i);
          } 
        }
    

    Para maiores informações consulte:

    http://msdn.microsoft.com/pt-br/library/system.windows.controls.datagrid.aspx

    domingo, 15 de maio de 2011 02:15
  • Obrigado Wesley!
    domingo, 15 de maio de 2011 14:43