I am working on attendance report. Here I am getting Headers Startdate to enddate between dates. my problem to create sub-columns under the headers. Below is the screenshot which I want to get data structure.
I want AM and PM under the startdate to enddate below is the code to get header dates.
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
Dim startDate As Date = CType(dtpStartDate.SelectedDate, DateTime)
Dim endDate As Date = CType(dtpEndDate.SelectedDate, DateTime)
While startDate <= endDate
Dim newColumn As DataGridTextColumn = New DataGridTextColumn()
newColumn.Header = startDate.ToShortDateString()
dgTemplate.Columns.Add(newColumn)
startDate = startDate.AddDays(1)
End While
End Sub
please help me to get sub-columns as AM and PM along with dates. Below XAML
<DataGrid x:Name="dgTemplate" Margin="261,0,0,0" >
<DatePicker x:Name="Startdate" HorizontalAlignment="Left" Margin="42,133,0,0" VerticalAlignment="Top"/>
<DatePicker x:Name="Enddate" HorizontalAlignment="Left" Margin="40,0,0,0" VerticalAlignment="Center"/>
<Button x:Name="Button" Click="Button_Click" Content="Button" HorizontalAlignment="Left" Margin="35,325,0,0" VerticalAlignment="Top"/>
<Window x:Class="test106.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:test106"
mc:Ignorable="d"
xmlns:mynamespace="clr-namespace:test106"
Title="MainWindow" Height="450" Width="800">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="{x:Type local:DataGridRowItem}">
<DataGrid ItemsSource="{Binding Columns[0].TableData}"
local:DataGridHelper.IsSynchronizeSelectedRowEnabled="True"
local:DataGridHelper.SynchronizeGroupKey="A"
RowHeaderWidth="0"
BorderThickness="0" />