OK I am working on this project now in wpf. I have to bring in data from a csv file on column 0,1 and 11. so far I have column 0,1,2 and not 11 figure i can get to that slowly. That is all I am pulling from the csv file.
In mt datagrid I get my 3 columns from the csv file no problem there. But when I try to figure out the column combox list I am having no luck. The items for the combobox are to be static and the same list will be used over and over again.
this is what I have so far.
and the cs side
In mt datagrid I get my 3 columns from the csv file no problem there. But when I try to figure out the column combox list I am having no luck. The items for the combobox are to be static and the same list will be used over and over again.
this is what I have so far.
xaml side:
<Window.DataContext>
<custom:GetCsvEmp/>
</Window.DataContext>
<Grid Background="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<DataGrid x:Name="EmpList" ItemsSource="{Binding EmpList}" Grid.Row="1" AutoGenerateColumns="False"
AlternatingRowBackground="PowderBlue" Padding="120,20" Background="Gray">
<DataGrid.Columns>
<DataGridTextColumn Header="Employee"
Binding="{Binding Path=EmpName}" Width="80"/>
<DataGridTextColumn Header="Payroll ID"
Binding="{Binding Path=EmpPayrollID}" Width="150"/>
<DataGridTextColumn Header="Job"
Binding="{Binding Path=JobName }" Width="110"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
and the cs side
class side:
class GetCsvEmp
{
public List<EmpCsvGet> EmpList { get; set; } = GetEmpget();
public static List<EmpCsvGet> GetEmpget()
{
var file = @"c:\rcs\export\timecard.csv";
var lines = File.ReadAllLines(file);
var list = new List<EmpCsvGet>();
for (int i = 0; i < lines.Length; i++)
{
var line = lines[i].Split(',');
var empCsvGet = new EmpCsvGet()
{
EmpName = line[0],
EmpPayrollID = line[1],
JobName = line[2]
};
list.Add(empCsvGet);
}
return list;
}
}
public class EmpCsvGet
{
// [Index(0)]
public string EmpName { get; set; }
// [Index(1)]
public string EmpPayrollID { get; set; }
//[Index(11)]
public string JobName { get; set; }
public string Monday { get; set; }
}