我试图在Datagrid中显示类似日期的SQL类型“Date”,而不是“Datetime”。 我不明白具体是我做错了什么。但它不起作用。
cmd.CommandText="SELECT Patient.Secondname as 'Фамилия', Patient.Name as 'Имя', Patient.Patronymic as 'Отчество', Patient.Adress as 'Адрес', Patient.Telephone as 'Номер телефона' FROM Patient";
cmd.CommandType=CommandType.Text;
adp=new SqlDataAdapter(cmd);
dtPat=new DataTable("Schedule");
adp.Fill(dtPat);
和
<DataGrid Name = "ScheduleCommon"
Margin = "2,0,4,0"
RenderTransformOrigin = "-0.21,0.4"
AutoGenerateColumns = "False"
EnableRowVirtualization = "True"
ItemsSource = "{Binding}">
< DataGrid.Columns >
< DataGridTextColumn Header = "ФИО" Binding = "{Binding apt.Name}"/>
< DataGridTextColumn Header = "Специализация" Binding = "{Binding apt.Specialisation}"/>
< DataGridTextColumn Header = "Дата" Binding = "{Binding apt.WorkDay, StringFormat=dd MM yyyy}"/>
< DataGridTextColumn Header = "С" Binding = "{Binding apt.TimeBegin}"/>
< DataGridTextColumn Header = "До"
Binding = "{Binding apt.TimeEnd}"/>
< /DataGrid.Columns>
</DataGrid >
答案 0 :(得分:0)
在属性窗口中,在“绑定”属性的右侧,您可以单击一个小方块,然后选择“创建绑定”。然后单击“更多参数”,然后您可以选择字符串格式
例如在这种情况下:
StringFormat=\{0:d\}}"