ListView with an empty and editable column

0

PersonnelwantedtohaveemptyandeditablecellsinacolumnofaListViewthatpullsinformationfromtheSQLServerdatabasetomyproject.TopulltheinformationIuseLINQandIcanlistallthedataIwant.Theideais:whenthislistisloadedtheusercaneditthecellsofanewcolumn(Quantity),theinformationthatwillbeenteredinthesecells(wholenumbers)willbeusedforothercalculationsintheproject.

IntheXMALcodeIamnotabletoleavethevaluesempty...Thatwayitisreturningthepathoftheclass.

Anyonewhocanhelpwillbeverygrateful!!

I'veattachedanimagetomakethequestioneasier...It'sintheQuantitycolumnthatthecellsneedtobeemptyandeditabletotheuser.ItisnotpartoftheSQLdatabase,displayonlyfortheusertoenterthedata.

  • XMALcode:

    <ListViewx:Name="listView_tabMaqPrda_ApontaPrd" Margin="99,117,915,583" 
               ItemsSource="{Binding}" ScrollViewer.CanContentScroll="True" 
               SelectionMode="Single">                              
    
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Código" Width="Auto" DisplayMemberBinding="{Binding CodigoParada}"/>
                <GridViewColumn Header="Descrição da Parada" Width="Auto" DisplayMemberBinding="{Binding DescricaoParada}"/>
                <GridViewColumn Header="Tempo(min)" Width="Auto" DisplayMemberBinding="{Binding TempoParada}"/>
                <GridViewColumn Header="Tipo de Parada" Width="Auto" DisplayMemberBinding="{Binding TipoParada}"/>
                <GridViewColumn Header="Quantidade" Width="Auto" />
            </GridView>
        </ListView.View>
    </ListView>
    

LINQ Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TRSSystem.AcessoDados
{
    public class tabMaquinaParadaAcesso
    {
//Consultar pela MAQUINA no Banco pela estrutura LINQ TO SQL Server
        public static List<tabMaquinaParada> Consultar_OnlyMaquina(string pMaquina, string pTipo)
        {
            TRSSystemDataClassesDataContext oDB = new TRSSystemDataClassesDataContext();
            List<tabMaquinaParada> aMaquina = (from Selecao in oDB.tabMaquinaParadas where Selecao.Maquina == pMaquina && Selecao.Sacaria == pTipo select Selecao).ToList<tabMaquinaParada>();
            return aMaquina;

        }

    }
}

LostFocus event of a Combox, when the list is loaded:

private void CarregarParadas_ApontaPrd(object sender, RoutedEventArgs e)
    {
        try
        {
            listView_tabMaqPrda_ApontaPrd.ItemsSource = TRSSystem.AcessoDados.tabMaquinaParadaAcesso.Consultar_OnlyMaquina(CmBox_MaquinaApontaPrd.Text, CmBox_TipoApontaPrd.Text);

        }catch(Exception error)
        {
            MessageBox.Show("Erro de Compilação, contacte o Administrador do Sistema." + error, "Erro de Compilação", MessageBoxButton.OK, MessageBoxImage.Error);
        }

    }
    
asked by anonymous 15.05.2016 / 01:52

2 answers

2

I have achieved this in a personal way ...

XMAL:

<GridViewColumn Header="Quantidade" Width="Auto">
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <TextBox Text="{Binding Path=Quantidade}" Width="30" MaxLength="2" 
                     HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="12" 
                     FontFamily="Calibri" HorizontalContentAlignment="Center"/>
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

Source: Populating ComboBox inside ListView in WPF

    
21.05.2016 / 16:25
1

In the same way that you declared the properties codeParada ,DesricaoParada and tempoParada in your class tabMaquinaParada, add another "quality" property but no values and add the binding in the code of the quality column to make the name of the class disappear, like this:

    
20.05.2016 / 20:23