0
People wanted to have empty and editable cells in a column of a Listview that pulls from the SQL Server Database information to my project. To pull the information I use LINQ and I can list all the data I want. The idea is: when loaded this list the user could edit the cells of a new column (Quantity), the information that will be inserted in these cells (whole numbers) will serve for other calculations in the project.
In XMAL code I am not able to leave the values empty... This way is returning the class path.
Anyone who can help I’d be most grateful!!
I attached an image to make it easier to doubt... It is in the Amount column that cells need is empty and editable for the user. It is not part of the SQL database, I display only for the user to enter the data.
XMAL code:
<ListView x: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 from a Combox, when loading the list:
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);
}
}
Good night, buddy. Like this?
– Felipe Cavalcante
<Gridviewcolumn Header="Quantity" Width="Auto" Displaymemberbinding="{Binding Quantity}"/>
– Felipe Cavalcante
That’s how it worked... That is, it returns empty. Post now I need to know how to make the cells in this column editable.
– Felipe Cavalcante
Exactly like that. Now, regarding making the column editable, I suggest you use a Datagrid, because Listview was developed only for the purpose of presenting data, not editing, that is the goal of Datagrid (Visualisar and manipulate data)or create a Textbox with Binding setting the Listview property you want to change.
– e200
Thank you... I switched to Datagrid... But when I type the values in the cells that I want to edit after leaving it, some of the ones that were typed... How do I make the data being edited visible?
– Felipe Cavalcante
I have no idea what’s going on with you, but I think you’ll find other questions that might answer your question. Any other questions just ask. Don’t forget to mark the question as answered. ;)
– e200
Friend... If you can help...http://answall.com/questions/130745/datagrid-editando-dates-apenas-n%C3%Bameros-e-calculando-seu-valores-wpf-c-co
– Felipe Cavalcante