FastReport使用List的方法

时间:2021-11-01 20:22:55

public class User
{
string username;
string password;

public User(string username, string password)
{
Username = username;
Password = password;
}

public string Username { get => username; set => username = value; }
public string Password { get => password; set => password = value; }
}

private void button1_Click(object sender, EventArgs e)
{
FastReport.Report report1 = new FastReport.Report();

List<User> list = new List<User>();
list.Add(new User("aaa","bbb"));
list.Add(new User("ccc", "ddd"));

try
{
report1.Load(@"C:\Users\zgj\Desktop\Untitled.frx");
report1.RegisterData(list,"aa");

report1.GetDataSource("aa").Enabled = true;
DataBand data = report1.Report.FindObject("Data1") as DataBand;
data.DataSource = report1.Report.GetDataSource("aa");
report1.Report.Show();
// report1.Report.Design();
/// report1.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
//throw;
}
}