2
Good night. I have one dataGrid
which I carry using Entity Framework, however in dataGrid
my date appears MM/dd/yyyy
, I want to remove the time and format the date to dd/mm/yyyy
, and in the validity field I want to remove only the hour part of the code that generates the dataGrid
Code
using (ConsultorioContext ctx = new ConsultorioContext())
{
var lista = ctx.Produtos.ToList();
return lista;
}
Datagrid
I tried to change the bank but I still have the same problem.
Good afternoon I could not apply, should I touch some part of the code besides this?
dgProdutos.Columns[4].DefaultCellStyle.Format = "dd/MM/yyyy"
me is returning the Datagridcolumn error does not contain a definition for "Defaultcellstyle" that accepts the first argument of type "Datagridcolumn"– Lucas Santos
dgProdutos
is not a 'Datagridview? Pergunto porque na pergunta está marcado a tag
Datagridviewe essa resposta só se aplica a
Datagridview. Se esse é o caso me informe a classe que
dgProducts` instance.– Augusto Vasques
this is the code in the xaml
<DataGrid x:Name="dgProdutos" Margin="78,172,70,243" IsReadOnly="True" MouseDoubleClick="DgProdutos_MouseDoubleClick" SelectionMode="Single" />
Part of datagrid mount codedgProdutos.ItemsSource = ProdutoViewModel.ExibirProdutos();
Remainder of the callusing (ConsultorioContext ctx = new ConsultorioContext()) 
 { 
 var lista = ctx.Produtos.ToList(); 
 return lista; 
 }
– Lucas Santos
Vasques, you were correct I am working with datagrid and not dataGridView, I did not know the difference between them.
– Lucas Santos
@Lucassantos I made the modification to Datagrid.
– Augusto Vasques
Perfect, thank you very much, really help me a lot
– Lucas Santos