-1

I made a program for calculating credits payments in C#, but I have some problem. Initially, I made a class,

public class Rate
{
    public int ID { get; set; }
    public double Principal { get; set; }
    public double Interest { get; set; }
    public double Insurance { get; set; }
    public int Commission { get; set; }
    public double TotalPayment { get; set; }
    public double CreditValue { get; set; }
}

After, I made another class, Data Context, which creates a list of Rates. I don't know how to create this list, for using later in a binding source for a data grid. In data grid form, i have some radio button and six text boxes for setting equal/descending payments, Credit Value, duration of credit(in month = number of rates), interest (%), insurance (%), commission analysis, monthly commission (%) and a button Calculate. After taking this value i need to calculate the payments and to show in data grid. Any idea how can I do this?

Sinjai
  • 1,085
  • 1
  • 15
  • 34

1 Answers1

0

Create the list like this

public ObservableCollection<Rate> MyList { get; set; }

and

public void InitializeMyList()
{
    MyList = new ObservableCollection<Rate>();
    for (int i = 0; i < 5; i++)
    {
        MyList.Add(new Rate() { ID = i, Interest = 2.0, Insurance = 0.5 });
    }
}

Then bind to it like this

<DataGrid ItemsSource="{Binding MyList}"/>

You can also define columns like this

<DataGrid ItemsSource="{Binding MyList}" AutoGenerateColumns="False">
    <DataGrid.Columns>
        <DataGridTextColumn Binding="{Binding ID}"/>
        <DataGridTextColumn Binding="{Binding Interest}"/>
        <DataGridTextColumn Binding="{Binding Insurance}"/>
    </DataGrid.Columns>
</DataGrid>

This tutorial and this question may be helpful too.

Gareth
  • 913
  • 6
  • 14