WPF更改同一表格上的三个数据网格的标题

时间:2018-12-01 16:01:01

标签: wpf vb.net

我正在使用WPF应用程序并将3个Datagrid放在3个选项卡中,我想更改每个Datagrid的标题名称,但是不幸的是,我的代码仅在第一个Datagrid中工作,而在其他两个网格中不工作

这是我的第一个数据网格代码:

 Dim dt As DataTable = New DataTable()
        Dim dc1 As DataColumn = New DataColumn("Emp_Code1", GetType(String))
        dc1.Caption = "كود الموظف"
        dt.Columns.Add(dc1)
        Dim dc2 As DataColumn = New DataColumn("Emp_Name1", GetType(String))
        dc2.Caption = "إسم الموظف"
        dt.Columns.Add(dc2)
        Dim dc3 As DataColumn = New DataColumn("Salary_col1", GetType(Decimal))
        dc3.Caption = "أساسي المرتب"
        dt.Columns.Add(dc3)
        Dim dc4 As DataColumn = New DataColumn("Hour_Value_col1", GetType(Decimal))
        dc4.Caption = "قيمة الساعة"
        dt.Columns.Add(dc4)
        Dim dc5 As DataColumn = New DataColumn("Over_Hours_col1", GetType(Decimal))
        dc5.Caption = "عدد ساعات الإضافي"
        dt.Columns.Add(dc5)
        Dim dc6 As DataColumn = New DataColumn("Trans_Value_col1", GetType(Decimal))
        dc6.Caption = "مقدار إحتساب الإضافي"
        dt.Columns.Add(dc6)
        Dim dc7 As DataColumn = New DataColumn("Total_OverTime_col1", GetType(Decimal))
        dc7.Caption = "إجمالي الإضافي"
        dt.Columns.Add(dc7)
        Dim dc8 As DataColumn = New DataColumn("Ikama_No1", GetType(String))
        dc8.Caption = "رقم السجل المدني"
        dt.Columns.Add(dc8)
        Dim dc9 As DataColumn = New DataColumn("ShowRoom_col1", GetType(String))
        dc9.Caption = "المعرض"
        dt.Columns.Add(dc9)
        Dim dc10 As DataColumn = New DataColumn("Time_Mor_from1", GetType(String))
        dc10.Caption = "صباحا من"
        dt.Columns.Add(dc10)
        Dim dc11 As DataColumn = New DataColumn("Time_Mor_to1", GetType(String))
        dc11.Caption = "صباحا إلي"
        dt.Columns.Add(dc11)
        Dim dc12 As DataColumn = New DataColumn("Time_eve_from1", GetType(String))
        dc12.Caption = "مساءا من"
        dt.Columns.Add(dc12)
        Dim dc13 As DataColumn = New DataColumn("Time_eve_to1", GetType(String))
        dc13.Caption = "مساءا إلي"
        dt.Columns.Add(dc13)
        Dim dc14 As DataColumn = New DataColumn("Date_Col1", GetType(String))
        dc14.Caption = "تاريخ اليوم"
        dt.Columns.Add(dc14)
        Dim dc15 As DataColumn = New DataColumn("Shift_Col1", GetType(String))
        dc15.Caption = "حالة الدوام"
        dt.Columns.Add(dc15)
        Dim dc16 As DataColumn = New DataColumn("Official_Hours1", GetType(String))
        dc16.Caption = " ساعات الدوام الرسمية باليوم"
        dt.Columns.Add(dc16)
        Dim dc17 As DataColumn = New DataColumn("Day_Shift_Hours1", GetType(String))
        dc17.Caption = "ساعات الدوام الحالية باليوم"
        dt.Columns.Add(dc17)
        Dim dc18 As DataColumn = New DataColumn("Day_Shift_Extra_Hours1", GetType(String))
        dc18.Caption = "ساعات الإضافي باليوم"
        dt.Columns.Add(dc18)
        Dim dc19 As DataColumn = New DataColumn("Month_Official_Hours1", GetType(String))
        dc19.Caption = "ساعات الدوام الرسمية بالشهر"
        dt.Columns.Add(dc19)
        Dim dc20 As DataColumn = New DataColumn("Month_Shift_Hours1", GetType(String))
        dc20.Caption = "ساعات الدوام الحالية بالشهر"
        dt.Columns.Add(dc20)
        Dim dc21 As DataColumn = New DataColumn("Month_Shift_Extra_Hours1", GetType(String))
        dc21.Caption = "ساعات الإضافي بالشهر"
        dt.Columns.Add(dc21)
        Dim dc22 As DataColumn = New DataColumn("Month_No1", GetType(String))
        dc22.Caption = "الشهر"
        dt.Columns.Add(dc22)
        Dim dc23 As DataColumn = New DataColumn("from_date1", GetType(String))
        dc23.Caption = "اعتبارا من تاريخ"
        dt.Columns.Add(dc23)
        Dim dc24 As DataColumn = New DataColumn("to_date1", GetType(String))
        dc24.Caption = "الي تاريخ"
        dt.Columns.Add(dc24)
        Dim dc25 As DataColumn = New DataColumn("Job1", GetType(String))
        dc25.Caption = "الوظيفة"
        dt.Columns.Add(dc25)

        Dawam_Grid.ItemsSource = dt.DefaultView
        For Each col As DataGridColumn In Dawam_Grid.Columns
            col.Header = dt.Columns(col.Header).Caption
        Next

这是第二个数据网格代码:

Dim dt2 As DataTable = New DataTable()
        Dim dc26 As DataColumn = New DataColumn("Emp_Code2", GetType(String))
        dc26.Caption = "كود الموظف"
        dt2.Columns.Add(dc26)
        Dim dc27 As DataColumn = New DataColumn("Emp_Name2", GetType(String))
        dc27.Caption = "إسم الموظف"
        dt2.Columns.Add(dc27)
        Dim dc28 As DataColumn = New DataColumn("Salary_col2", GetType(Decimal))
        dc28.Caption = "أساسي المرتب"
        dt2.Columns.Add(dc28)
        Dim dc29 As DataColumn = New DataColumn("Hour_Value_col2", GetType(Decimal))
        dc29.Caption = "قيمة الساعة"
        dt2.Columns.Add(dc29)
        Dim dc30 As DataColumn = New DataColumn("Over_Hours_col2", GetType(Decimal))
        dc30.Caption = "عدد ساعات الإضافي"
        dt2.Columns.Add(dc30)
        Dim dc31 As DataColumn = New DataColumn("Trans_Value_col2", GetType(Decimal))
        dc31.Caption = "مقدار إحتساب الإضافي"
        dt2.Columns.Add(dc31)
        Dim dc32 As DataColumn = New DataColumn("Total_OverTime_col2", GetType(Decimal))
        dc32.Caption = "إجمالي الإضافي"
        dt2.Columns.Add(dc32)
        Dim dc33 As DataColumn = New DataColumn("Ikama_No2", GetType(String))
        dc33.Caption = "رقم السجل المدني"
        dt2.Columns.Add(dc33)
        Dim dc34 As DataColumn = New DataColumn("ShowRoom_col2", GetType(String))
        dc34.Caption = "المعرض"
        dt2.Columns.Add(dc34)
        Dim dc35 As DataColumn = New DataColumn("Time_Mor_from2", GetType(String))
        dc35.Caption = "صباحا من"
        dt2.Columns.Add(dc35)
        Dim dc36 As DataColumn = New DataColumn("Time_Mor_to2", GetType(String))
        dc36.Caption = "صباحا إلي"
        dt2.Columns.Add(dc36)
        Dim dc37 As DataColumn = New DataColumn("Time_eve_from2", GetType(String))
        dc37.Caption = "مساءا من"
        dt2.Columns.Add(dc37)
        Dim dc38 As DataColumn = New DataColumn("Time_eve_to2", GetType(String))
        dc38.Caption = "مساءا إلي"
        dt2.Columns.Add(dc38)
        Dim dc39 As DataColumn = New DataColumn("Date_Col2", GetType(String))
        dc39.Caption = "تاريخ اليوم"
        dt2.Columns.Add(dc39)
        Dim dc40 As DataColumn = New DataColumn("Shift_Col2", GetType(String))
        dc40.Caption = "حالة الدوام"
        dt2.Columns.Add(dc40)
        Dim dc41 As DataColumn = New DataColumn("Official_Hours2", GetType(String))
        dc41.Caption = " ساعات الدوام الرسمية باليوم"
        dt2.Columns.Add(dc41)
        Dim dc42 As DataColumn = New DataColumn("Day_Shift_Hours2", GetType(String))
        dc42.Caption = "ساعات الدوام الحالية باليوم"
        dt2.Columns.Add(dc42)
        Dim dc43 As DataColumn = New DataColumn("Day_Shift_Extra_Hours2", GetType(String))
        dc43.Caption = "ساعات الإضافي باليوم"
        dt2.Columns.Add(dc43)
        Dim dc44 As DataColumn = New DataColumn("Month_Official_Hours2", GetType(String))
        dc44.Caption = "ساعات الدوام الرسمية بالشهر"
        dt2.Columns.Add(dc44)
        Dim dc45 As DataColumn = New DataColumn("Month_Shift_Hours2", GetType(String))
        dc45.Caption = "ساعات الدوام الحالية بالشهر"
        dt2.Columns.Add(dc45)
        Dim dc46 As DataColumn = New DataColumn("Month_Shift_Extra_Hours2", GetType(String))
        dc46.Caption = "ساعات الإضافي بالشهر"
        dt2.Columns.Add(dc46)
        Dim dc47 As DataColumn = New DataColumn("Month_No2", GetType(String))
        dc47.Caption = "الشهر"
        dt2.Columns.Add(dc47)
        Dim dc48 As DataColumn = New DataColumn("from_date2", GetType(String))
        dc48.Caption = "اعتبارا من تاريخ"
        dt2.Columns.Add(dc48)
        Dim dc49 As DataColumn = New DataColumn("to_date2", GetType(String))
        dc49.Caption = "الي تاريخ"
        dt2.Columns.Add(dc49)
        Dim dc50 As DataColumn = New DataColumn("Job2", GetType(String))
        dc50.Caption = "الوظيفة"
        dt2.Columns.Add(dc50)


        dataGrid1.ItemsSource = dt2.DefaultView
        For Each col2 As DataGridColumn In dataGrid1.Columns
            col2.Header = dt2.Columns(col2.Header).Caption
        Next

这是更多的代码:

Dim dt3 As DataTable = New DataTable()
        Dim dc51 As DataColumn = New DataColumn("Emp_Code3", GetType(String))
        dc51.Caption = "كود الموظف"
        dt3.Columns.Add(dc51)
        Dim dc52 As DataColumn = New DataColumn("Emp_Name3", GetType(String))
        dc52.Caption = "إسم الموظف"
        dt3.Columns.Add(dc52)
        Dim dc53 As DataColumn = New DataColumn("Sat", GetType(String))
        dc53.Caption = "السبت"
        dt3.Columns.Add(dc53)
        Dim dc54 As DataColumn = New DataColumn("Sun", GetType(String))
        dc54.Caption = "الأحد"
        dt3.Columns.Add(dc54)
        Dim dc55 As DataColumn = New DataColumn("Mon", GetType(String))
        dc55.Caption = "الإثنين"
        dt3.Columns.Add(dc55)
        Dim dc56 As DataColumn = New DataColumn("Tus", GetType(String))
        dc56.Caption = "الثلاثاء"
        dt3.Columns.Add(dc56)
        Dim dc57 As DataColumn = New DataColumn("Wed", GetType(String))
        dc57.Caption = "الأربعاء"
        dt3.Columns.Add(dc57)
        Dim dc58 As DataColumn = New DataColumn("Thu", GetType(String))
        dc58.Caption = "الخميس"
        dt3.Columns.Add(dc58)
        Dim dc59 As DataColumn = New DataColumn("Fri", GetType(String))
        dc59.Caption = "الجمعة"
        dt3.Columns.Add(dc59)
        Dim dc60 As DataColumn = New DataColumn("Job3", GetType(String))
        dc60.Caption = "الوظيفة"
        dt3.Columns.Add(dc60)
        Dim dc61 As DataColumn = New DataColumn("Shop3", GetType(String))
        dc61.Caption = "المعرض"
        dt3.Columns.Add(dc61)
        Dim dc62 As DataColumn = New DataColumn("from_date3", GetType(String))
        dc62.Caption = "من تاريخ"
        dt3.Columns.Add(dc62)
        Dim dc63 As DataColumn = New DataColumn("to_date3", GetType(String))
        dc63.Caption = "الي تاريخ"
        dt3.Columns.Add(dc63)
        Dim dc64 As DataColumn = New DataColumn("Month_Official_Hours3", GetType(String))
        dc64.Caption = "الدوام الرسمي بالشهر"
        dt3.Columns.Add(dc64)
        Dim dc65 As DataColumn = New DataColumn("Month_Shift_Hours3", GetType(String))
        dc65.Caption = "الدوام الحالي بالشهر"
        dt3.Columns.Add(dc65)
        Dim dc66 As DataColumn = New DataColumn("Month_Shift_Extra_Hours3", GetType(String))
        dc66.Caption = "الوقت الاضافي بالشهر"
        dt3.Columns.Add(dc66)



        ShowRooms_Grid.ItemsSource = dt3.DefaultView
        For Each col3 As DataGridColumn In ShowRooms_Grid.Columns
            col3.Header = dt3.Columns(col3.Header).Caption
        Next

您能检查一下此代码中的错误吗?

2 个答案:

答案 0 :(得分:0)

我调试了代码,发现 dataGrid1.Columns ShowRooms_Grid.Columns 的列数为零,并且没有进入提供阿拉伯文标题文本的循环

我默认选择了第二个Tabitem。

<TabItem Header="TabItem" Selector.IsSelected="True">

这样,只有选定的第二个TabItem数据网格具有您的阿拉伯文本标题。

Datagrid列是自动生成的,但尚未生成,因为我没有看到它在选项卡中显示。

我建议您通过使AutoGenerateColumns="False"

在Xaml中创建Datagrid列
<DataGrid HorizontalAlignment="Left" Height="252" Margin="0,10,0,0" VerticalAlignment="Top" x:Name="dataGrid1" Width="659">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="Your Header" Binding="{ColumnName}"/>
                    </DataGrid.Columns>
</DataGrid>

替代解决方案:-如果您不想使用Xaml,则可以编写3种不同的方法,并在每个Tabitem加载事件上分别调用。

答案 1 :(得分:0)

我找到了解决方法。

我在xaml中为三个Datagrid创建了列,然后创建了3个Public类,然后以编程方式将值传递给每个Datagrid的新行。这是我的新代码:

第一个网格->

 <DataGrid x:Name="Dawam_Grid" AutoGenerateColumns="False" CanUserAddRows="True" ItemsSource="{Binding Dawam_Grid_ItemsBinding}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="كود الموظف" x:Name="Emp_Code1" IsReadOnly="True" Binding="{Binding Path=Emp_Code1}" Foreground="Black"/>
                            <DataGridTextColumn Header="إسم الموظف" x:Name="Emp_Name1" IsReadOnly="True" Binding="{Binding Path=Emp_Name1}" Foreground="Black"/>
                            <DataGridTextColumn Header="المرتب" x:Name="Salary_col1" IsReadOnly="True" Binding="{Binding Path=Salary_col1}" Foreground="Black"/>
                            <DataGridTextColumn Header="قيمة الساعة" x:Name="Hour_Value_col1" IsReadOnly="True" Binding="{Binding Path=Hour_Value_col1}" Foreground="Black"/>
                            <DataGridTextColumn Header="عدد ساعات الإضافي" x:Name="Over_Hours_col1" IsReadOnly="True" Binding="{Binding Path=Over_Hours_col1}" Foreground="Black"/>
                            <DataGridTextColumn Header="مقدار إحتساب الإضافي" x:Name="Trans_Value_col1" IsReadOnly="True" Binding="{Binding Path=Trans_Value_col1}" Foreground="Black"/>
                            <DataGridTextColumn Header="إجمالي الإضافي" x:Name="Total_OverTime_col1" IsReadOnly="True" Binding="{Binding Path=Total_OverTime_col1}" Foreground="Black"/>
                            <DataGridTextColumn Header="رقم السجل المدني" x:Name="Ikama_No1" IsReadOnly="True" Binding="{Binding Path=Ikama_No1}" Foreground="Black"/>
                            <DataGridTextColumn Header="المعرض" x:Name="ShowRoom_col1" IsReadOnly="True" Binding="{Binding Path=ShowRoom_col1}" Foreground="Black"/>
                            <DataGridTextColumn Header="صباحا من" x:Name="Time_Mor_from1" IsReadOnly="True" Binding="{Binding Path=Time_Mor_from1}" Foreground="Black"/>
                            <DataGridTextColumn Header="صباحا إلي" x:Name="Time_Mor_to1" IsReadOnly="True" Binding="{Binding Path=Time_Mor_to1}" Foreground="Black"/>
                            <DataGridTextColumn Header="مساءا من" x:Name="Time_eve_from1" IsReadOnly="True" Binding="{Binding Path=Time_eve_from1}" Foreground="Black"/>
                            <DataGridTextColumn Header="مساءا إلي" x:Name="Time_eve_to1" IsReadOnly="True" Binding="{Binding Path=Time_eve_to1}" Foreground="Black"/>
                            <DataGridTextColumn Header="تاريخ اليوم" x:Name="Date_Col1" IsReadOnly="True" Binding="{Binding Path=Date_Col1}" Foreground="Black"/>
                            <DataGridTextColumn Header="حالة الدوام" x:Name="Shift_Col1" IsReadOnly="True" Binding="{Binding Path=Official_Hours1}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الدوام الرسمي باليوم" x:Name="Official_Hours1" IsReadOnly="True" Binding="{Binding Path=Day_Shift_Hours1}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الدوام الحالية باليوم" x:Name="Day_Shift_Hours1" IsReadOnly="True" Binding="{Binding Path=Day_Shift_Extra_Hours1}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الإضافي باليوم" x:Name="Day_Shift_Extra_Hours1" IsReadOnly="True" Binding="{Binding Path=Month_Official_Hours1}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الدوام الرسمية بالشهر" x:Name="Month_Official_Hours1" IsReadOnly="True" Binding="{Binding Path=Month_Shift_Hours1}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الدوام الحالية بالشهر" x:Name="Month_Shift_Hours1" IsReadOnly="True" Binding="{Binding Path=Month_Shift_Extra_Hours1}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الإضافي بالشهر" x:Name="Month_Shift_Extra_Hours1" IsReadOnly="True" Binding="{Binding Path=Shift_Col1}" Foreground="Black"/>
                            <DataGridTextColumn Header= "الشهر" x:Name="Month_No1" IsReadOnly="True" Binding="{Binding Path=Month_No1}" Foreground="Black"/>
                            <DataGridTextColumn Header= "اعتبارا من تاريخ" x:Name="from_date1" IsReadOnly="True" Binding="{Binding Path=from_date1}" Foreground="Black"/>
                            <DataGridTextColumn Header="الي تاريخ" x:Name="to_date1" IsReadOnly="True" Binding="{Binding Path=to_date1}" Foreground="Black"/>
                            <DataGridTextColumn Header= "الوظيفة" x:Name="Job1" IsReadOnly="True" Binding="{Binding Path=Job1}" Foreground="Black"/>
                        </DataGrid.Columns>
                    </DataGrid>

第二个网格->

<DataGrid x:Name="dataGrid1" AutoGenerateColumns="False" CanUserAddRows="True" ItemsSource="{Binding dataGrid1_ItemsBinding}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header= "كود الموظف" x:Name="Emp_Code2" IsReadOnly="True" Binding="{Binding Path=Emp_Code2}" Foreground="Black"/>
                            <DataGridTextColumn Header="إسم الموظف" x:Name="Emp_Name2" IsReadOnly="True" Binding="{Binding Path=Emp_Name2}" Foreground="Black"/>
                            <DataGridTextColumn Header= "أساسي المرتب" x:Name="Salary_col2" IsReadOnly="True" Binding="{Binding Path=Salary_col2}" Foreground="Black"/>
                            <DataGridTextColumn Header="قيمة الساعة" x:Name="Hour_Value_col2" IsReadOnly="True" Binding="{Binding Path=Hour_Value_col2}" Foreground="Black"/>
                            <DataGridTextColumn Header="عدد ساعات الإضافي" x:Name="Over_Hours_col2" IsReadOnly="True" Binding="{Binding Path=Over_Hours_col2}" Foreground="Black"/>
                            <DataGridTextColumn Header="مقدار إحتساب الإضافي" x:Name="Trans_Value_col2" IsReadOnly="True" Binding="{Binding Path=Trans_Value_col2}" Foreground="Black"/>
                            <DataGridTextColumn Header="إجمالي الإضافي" x:Name="Total_OverTime_col2" IsReadOnly="True" Binding="{Binding Path=Total_OverTime_col2}" Foreground="Black"/>
                            <DataGridTextColumn Header= "رقم السجل المدني" x:Name="Ikama_No2" IsReadOnly="True" Binding="{Binding Path=Ikama_No2}" Foreground="Black"/>
                            <DataGridTextColumn Header="المعرض" x:Name="ShowRoom_col2" IsReadOnly="True" Binding="{Binding Path=ShowRoom_col2}" Foreground="Black"/>
                            <DataGridTextColumn Header="صباحا من" x:Name="Time_Mor_from2" IsReadOnly="True" Binding="{Binding Path=Time_Mor_from2}" Foreground="Black"/>
                            <DataGridTextColumn Header="صباحا إلي" x:Name="Time_Mor_to2" IsReadOnly="True" Binding="{Binding Path=Time_Mor_to2}" Foreground="Black"/>
                            <DataGridTextColumn Header= "مساءا من" x:Name="Time_eve_from2" IsReadOnly="True" Binding="{Binding Path=Time_eve_from2}" Foreground="Black"/>
                            <DataGridTextColumn Header="مساءا إلي" x:Name="Time_eve_to2" IsReadOnly="True" Binding="{Binding Path=Time_eve_to2}" Foreground="Black"/>
                            <DataGridTextColumn Header= "تاريخ اليوم" x:Name="Date_Col2" IsReadOnly="True" Binding="{Binding Path=Date_Col2}" Foreground="Black"/>
                            <DataGridTextColumn Header= "حالة الدوام" x:Name="Shift_Col2" IsReadOnly="True" Binding="{Binding Path=Official_Hours2}" Foreground="Black"/>
                            <DataGridTextColumn Header=" ساعات الدوام الرسمية باليوم" x:Name="Official_Hours2" IsReadOnly="True" Binding="{Binding Path=Day_Shift_Hours2}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الدوام الحالية باليوم" x:Name="Day_Shift_Hours2" IsReadOnly="True" Binding="{Binding Path=Day_Shift_Extra_Hours2}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الإضافي باليوم" x:Name="Day_Shift_Extra_Hours2" IsReadOnly="True" Binding="{Binding Path=Month_Official_Hours2}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الدوام الرسمية بالشهر" x:Name="Month_Official_Hours2" IsReadOnly="True" Binding="{Binding Path=Month_Shift_Hours2}" Foreground="Black"/>
                            <DataGridTextColumn Header="ساعات الدوام الحالية بالشهر" x:Name="Month_Shift_Hours2" IsReadOnly="True" Binding="{Binding Path=Month_Shift_Extra_Hours2}" Foreground="Black"/>
                            <DataGridTextColumn Header= "ساعات الإضافي بالشهر" x:Name="Month_Shift_Extra_Hours2" IsReadOnly="True" Binding="{Binding Path=Shift_Col2}" Foreground="Black"/>
                            <DataGridTextColumn Header="الشهر" x:Name="Month_No2" IsReadOnly="True" Binding="{Binding Path=Month_No2}" Foreground="Black"/>
                            <DataGridTextColumn Header="اعتبارا من تاريخ" x:Name="from_date2" IsReadOnly="True" Binding="{Binding Path=from_date2}" Foreground="Black"/>
                            <DataGridTextColumn Header= "الي تاريخ" x:Name="to_date2" IsReadOnly="True" Binding="{Binding Path=to_date2}" Foreground="Black"/>
                            <DataGridTextColumn Header="الوظيفة" x:Name="Job2" IsReadOnly="True" Binding="{Binding Path=Job2}" Foreground="Black"/>
                        </DataGrid.Columns>
                        </DataGrid>

第三个网格->

<DataGrid x:Name="ShowRooms_Grid" AutoGenerateColumns="False" CanUserAddRows="True" ItemsSource="{Binding ShowRooms_Grid_ItemsBinding}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="كود الموظف" x:Name="Emp_Code3" IsReadOnly="True" Binding="{Binding Path=Emp_Code3}" Foreground="Black"/>
                            <DataGridTextColumn Header="إسم الموظف" x:Name="Emp_Name3" IsReadOnly="True" Binding="{Binding Path=Emp_Name3}" Foreground="Black"/>
                            <DataGridTextColumn Header= "السبت" x:Name="Sat" IsReadOnly="True" Binding="{Binding Path=Sat}" Foreground="Black"/>
                            <DataGridTextColumn Header="الأحد" x:Name="Sun" IsReadOnly="True" Binding="{Binding Path=Sun}" Foreground="Black"/>
                            <DataGridTextColumn Header="الإثنين" x:Name="Mon" IsReadOnly="True" Binding="{Binding Path=Mon}" Foreground="Black"/>
                            <DataGridTextColumn Header= "الثلاثاء" x:Name="Tus" IsReadOnly="True" Binding="{Binding Path=Tus}" Foreground="Black"/>
                            <DataGridTextColumn Header="الأربعاء" x:Name="Wed" IsReadOnly="True" Binding="{Binding Path=Wed}" Foreground="Black"/>
                            <DataGridTextColumn Header="الخميس" x:Name="Thu" IsReadOnly="True" Binding="{Binding Path=Thu}" Foreground="Black"/>
                            <DataGridTextColumn Header= "الجمعة" x:Name="Fri" IsReadOnly="True" Binding="{Binding Path=Fri}" Foreground="Black"/>
                            <DataGridTextColumn Header="الوظيفة" x:Name="Job3" IsReadOnly="True" Binding="{Binding Path=Job3}" Foreground="Black"/>
                            <DataGridTextColumn Header="المعرض" x:Name="Shop3" IsReadOnly="True" Binding="{Binding Path=Shop3}" Foreground="Black"/>
                            <DataGridTextColumn Header="من تاريخ" x:Name="from_date3" IsReadOnly="True" Binding="{Binding Path=from_date3}" Foreground="Black"/>
                            <DataGridTextColumn Header= "الي تاريخ" x:Name="to_date3" IsReadOnly="True" Binding="{Binding Path=to_date3}" Foreground="Black"/>
                            <DataGridTextColumn Header="الدوام الرسمي بالشهر" x:Name="Month_Official_Hours3" IsReadOnly="True" Binding="{Binding Path=Month_Official_Hours3}" Foreground="Black"/>
                            <DataGridTextColumn Header="الدوام الحالي بالشهر" x:Name="Month_Shift_Hours3" IsReadOnly="True" Binding="{Binding Path=Month_Shift_Hours3}" Foreground="Black"/>
                            <DataGridTextColumn Header= "الوقت الاضافي بالشهر" x:Name="Month_Shift_Extra_Hours3" IsReadOnly="True" Binding="{Binding Path=Month_Shift_Extra_Hours3}" Foreground="Black"/>
                        </DataGrid.Columns>
                    </DataGrid>

公共课->

Public Class Dawam_Grid_Items

        Public Property Emp_Code1 As String
        Public Property Emp_Name1 As String
        Public Property Salary_col1 As String
        Public Property Hour_Value_col1 As String
        Public Property Over_Hours_col1 As String
        Public Property Trans_Value_col1 As String
        Public Property Total_OverTime_col1 As String
        Public Property Ikama_No1 As String
        Public Property ShowRoom_col1 As String
        Public Property Time_Mor_from1 As String
        Public Property Time_Mor_to1 As String
        Public Property Time_eve_from1 As String
        Public Property Time_eve_to1 As String
        Public Property Date_Col1 As String
        Public Property Official_Hours1 As String
        Public Property Day_Shift_Hours1 As String
        Public Property Day_Shift_Extra_Hours1 As String
        Public Property Month_Official_Hours1 As String
        Public Property Month_Shift_Hours1 As String
        Public Property Month_Shift_Extra_Hours1 As String
        Public Property Shift_Col1 As String
        Public Property Month_No1 As String
        Public Property from_date1 As String
        Public Property to_date1 As String
        Public Property Job1 As String

    End Class



    Public Class dataGrid1_Items

        Public Property Emp_Code2 As String
        Public Property Emp_Name2 As String
        Public Property Salary_col2 As String
        Public Property Hour_Value_col2 As String
        Public Property Over_Hours_col2 As String
        Public Property Trans_Value_col2 As String
        Public Property Total_OverTime_col2 As String
        Public Property Ikama_No2 As String
        Public Property ShowRoom_col2 As String
        Public Property Time_Mor_from2 As String
        Public Property Time_Mor_to2 As String
        Public Property Time_eve_from2 As String
        Public Property Time_eve_to2 As String
        Public Property Date_Col2 As String
        Public Property Official_Hours2 As String
        Public Property Day_Shift_Hours2 As String
        Public Property Day_Shift_Extra_Hours2 As String
        Public Property Month_Official_Hours2 As String
        Public Property Month_Shift_Hours2 As String
        Public Property Month_Shift_Extra_Hours2 As String
        Public Property Shift_Col2 As String
        Public Property Month_No2 As String
        Public Property from_date2 As String
        Public Property to_date2 As String
        Public Property Job2 As String

    End Class



    Public Class ShowRooms_Grid_Items

        Public Property Emp_Code3 As String
        Public Property Emp_Name3 As String
        Public Property Sat As String
        Public Property Sun As String
        Public Property Mon As String
        Public Property Tus As String
        Public Property Wed As String
        Public Property Thu As String
        Public Property Fri As String
        Public Property Job3 As String
        Public Property Shop3 As String
        Public Property from_date3 As String
        Public Property to_date3 As String
        Public Property Month_Official_Hours3 As String
        Public Property Month_Shift_Hours3 As String
        Public Property Month_Shift_Extra_Hours3 As String
    End Class

传递代码->

 Dim data = New ShowRooms_Grid_Items With {
        .Emp_Code3 = Emp_Code_txt.Text,
        .Emp_Name3 = Emp_Name_txt.Text,
        .Sat = SAT_txt.Text,
        .Sun = SUN_txt.Text,
        .Mon = MON_txt.Text,
        .Tus = TUS_txt.Text,
        .Wed = WED_txt.Text,
        .Thu = THU_txt.Text,
        .Fri = FRI_txt.Text,
        .Job3 = Emp_Job_txt.Text,
        .Shop3 = Showroom_txt.Text,
        .from_date3 = Format(From_Date.EditValue, ("yyyy-MM-dd")),
        .to_date3 = Format(To_Date.EditValue, ("yyyy-MM-dd")),
        .Month_Official_Hours3 = Month_Official_Hours.Text,
        .Month_Shift_Hours3 = Month_Shift_Hours.Text,
        .Month_Shift_Extra_Hours3 = Month_Shift_Extra_Hours.Text
    }
            ShowRooms_Grid.Items.Add(data)


            For i As Integer = 0 To On_Days_list.Items.Count - 1
                If (On_Days_list.Items(i).ToString.Contains("الجمعة")) Or (On_Days_list.Items(i).ToString.Contains("Friday")) Then
                    Dim data2 = New Dawam_Grid_Items With {
                .Emp_Code1 = Emp_Code_txt.Text,
                .Emp_Name1 = Emp_Name_txt.Text,
                .Salary_col1 = Emp_Salary_txt.Text,
                .Hour_Value_col1 = Hour_Price_txt.Text,
                .Over_Hours_col1 = Hours_Count_txt.Text,
                .Trans_Value_col1 = How_Much_txt.Text,
                .Total_OverTime_col1 = OverTime_txt.Text,
                .Ikama_No1 = Emp_Ikama_txt.Text,
                .ShowRoom_col1 = Showroom_txt.Text,
                .Time_Mor_from1 = "00:00:00",
                .Time_Mor_to1 = "00:00:00",
                .Time_eve_from1 = "15:30:00",
                .Time_eve_to1 = "22:30:00",
                .Date_Col1 = On_Days_list.Items(i),
                .Official_Hours1 = "07:00:00",
                .Day_Shift_Hours1 = "07:00:00",
                 .Day_Shift_Extra_Hours1 = "00:00:00",
            .Month_Official_Hours1 = Month_Official_Hours.Text,
            .Month_Shift_Hours1 = Month_Shift_Hours.Text,
            .Month_Shift_Extra_Hours1 = Month_Shift_Extra_Hours.Text,
            .Shift_Col1 = "فترة واحدة",
            .Month_No1 = Month_txt.Text,
            .from_date1 = Format(From_Date.EditValue, ("yyyy-MM-dd")),
            .to_date1 = Format(To_Date.EditValue, ("yyyy-MM-dd")),
            .Job1 = Emp_Job_txt.Text
            }
                    Dawam_Grid.Items.Add(data2)
                Else
                    Dim data2 = New Dawam_Grid_Items With {
               .Emp_Code1 = Emp_Code_txt.Text,
               .Emp_Name1 = Emp_Name_txt.Text,
               .Salary_col1 = Emp_Salary_txt.Text,
               .Hour_Value_col1 = Hour_Price_txt.Text,
               .Over_Hours_col1 = Hours_Count_txt.Text,
               .Trans_Value_col1 = How_Much_txt.Text,
               .Total_OverTime_col1 = OverTime_txt.Text,
               .Ikama_No1 = Emp_Ikama_txt.Text,
               .ShowRoom_col1 = Showroom_txt.Text,
               .Time_Mor_from1 = DateTime.ParseExact(Mor_from_txt.Text.ToString, "HH:mm", System.Globalization.CultureInfo.InvariantCulture),
               .Time_Mor_to1 = DateTime.ParseExact(Mor_To_txt.Text.ToString, "HH:mm", System.Globalization.CultureInfo.InvariantCulture),
               .Time_eve_from1 = DateTime.ParseExact(Eve_from_txt.Text.ToString, "HH:mm", System.Globalization.CultureInfo.InvariantCulture),
               .Time_eve_to1 = DateTime.ParseExact(Eve_To_txt.Text.ToString, "HH:mm", System.Globalization.CultureInfo.InvariantCulture),
               .Date_Col1 = On_Days_list.Items(i),
               .Official_Hours1 = DateTime.ParseExact(Official_Hours.Text.ToString, "HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture),
               .Day_Shift_Hours1 = DateTime.ParseExact(Day_Shift_Hours.Text.ToString, "HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture),
                .Day_Shift_Extra_Hours1 = DateTime.ParseExact(Day_Shift_Extra_Hours.Text.ToString, "HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture),
           .Month_Official_Hours1 = Month_Official_Hours.Text,
           .Month_Shift_Hours1 = Month_Shift_Hours.Text,
           .Month_Shift_Extra_Hours1 = Month_Shift_Extra_Hours.Text,
           .Shift_Col1 = "فترتين",
           .Month_No1 = Month_txt.Text,
           .from_date1 = Format(From_Date.EditValue, ("yyyy-MM-dd")),
           .to_date1 = Format(To_Date.EditValue, ("yyyy-MM-dd")),
           .Job1 = Emp_Job_txt.Text
           }
                    Dawam_Grid.Items.Add(data2)

                End If
            Next













            Dim data3 = New dataGrid1_Items With {
               .Emp_Code2 = Emp_Code_txt.Text,
               .Emp_Name2 = Emp_Name_txt.Text,
               .Salary_col2 = Emp_Salary_txt.Text,
               .Hour_Value_col2 = Hour_Price_txt.Text,
               .Over_Hours_col2 = Hours_Count_txt.Text,
               .Trans_Value_col2 = How_Much_txt.Text,
               .Total_OverTime_col2 = OverTime_txt.Text,
               .Ikama_No2 = Emp_Ikama_txt.Text,
               .ShowRoom_col2 = Showroom_txt.Text,
               .Time_Mor_from2 = DateTime.ParseExact(Mor_from_txt.Text.ToString, "HH:mm", System.Globalization.CultureInfo.InvariantCulture),
               .Time_Mor_to2 = DateTime.ParseExact(Mor_To_txt.Text.ToString, "HH:mm", System.Globalization.CultureInfo.InvariantCulture),
               .Time_eve_from2 = DateTime.ParseExact(Eve_from_txt.Text.ToString, "HH:mm", System.Globalization.CultureInfo.InvariantCulture),
               .Time_eve_to2 = DateTime.ParseExact(Eve_To_txt.Text.ToString, "HH:mm", System.Globalization.CultureInfo.InvariantCulture),
               .Date_Col2 = On_Days_list.Items(1),
               .Official_Hours2 = DateTime.ParseExact(Official_Hours.Text.ToString, "HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture),
               .Day_Shift_Hours2 = DateTime.ParseExact(Day_Shift_Hours.Text.ToString, "HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture),
                .Day_Shift_Extra_Hours2 = DateTime.ParseExact(Day_Shift_Extra_Hours.Text.ToString, "HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture),
           .Month_Official_Hours2 = Month_Official_Hours.Text,
           .Month_Shift_Hours2 = Month_Shift_Hours.Text,
           .Month_Shift_Extra_Hours2 = Month_Shift_Extra_Hours.Text,
           .Shift_Col2 = "فترتين",
           .Month_No2 = Month_txt.Text,
           .from_date2 = Format(From_Date.EditValue, ("yyyy-MM-dd")),
           .to_date2 = Format(To_Date.EditValue, ("yyyy-MM-dd")),
           .Job2 = Emp_Job_txt.Text
           }
            dataGrid1.Items.Add(data3)




            Dim Eve_From As TimeSpan = New TimeSpan(15, 30, 0)
            For i As Integer = 0 To Off_Days_list.Items.Count - 1
                Dim data2 = New Dawam_Grid_Items With {
             .Emp_Code1 = Emp_Code_txt.Text,
             .Emp_Name1 = Emp_Name_txt.Text,
             .Salary_col1 = Emp_Salary_txt.Text,
             .Hour_Value_col1 = Hour_Price_txt.Text,
             .Over_Hours_col1 = Hours_Count_txt.Text,
             .Trans_Value_col1 = How_Much_txt.Text,
             .Total_OverTime_col1 = OverTime_txt.Text,
             .Ikama_No1 = Emp_Ikama_txt.Text,
             .ShowRoom_col1 = Showroom_txt.Text,
             .Time_Mor_from1 = "00:00:00",
             .Time_Mor_to1 = "00:00:00",
             .Time_eve_from1 = "00:00:00",
             .Time_eve_to1 = "00:00:00",
             .Date_Col1 = Off_Days_list.Items(i),
             .Official_Hours1 = "00:00:00",
             .Day_Shift_Hours1 = "00:00:00",
              .Day_Shift_Extra_Hours1 = "00:00:00",
         .Month_Official_Hours1 = Month_Official_Hours.Text,
         .Month_Shift_Hours1 = Month_Shift_Hours.Text,
         .Month_Shift_Extra_Hours1 = Month_Shift_Extra_Hours.Text,
         .Shift_Col1 = "إجازة",
         .Month_No1 = Month_txt.Text,
         .from_date1 = Format(From_Date.EditValue, ("yyyy-MM-dd")),
         .to_date1 = Format(To_Date.EditValue, ("yyyy-MM-dd")),
         .Job1 = Emp_Job_txt.Text
         }
                Dawam_Grid.Items.Add(data2)