本文介绍了如何在C#Dot Net中显示从Sql到Combobox的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System;

使用System.Collections.Generic;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Windows.Forms ;



命名空间Dynamic.Account.Report.Transaction

{

公共部分类FrmRptTrialBalanceMonthly:Form // FrmReportBaseForm< dynamic.reportentity.account.trialbalance>

{

Dynamic.Reporting.Account.TrialBalanceSheetMonthly TrialBalanceMonthly = new Dynamic.Reporting.Account.TrialBalanceSheetMonthly();

public FrmRptTrialBalanceMonthly()

{

InitializeComponent();



System.Windows。 Forms.Control.CheckForIllegalCrossThreadCalls = false;

this.TabText =Ledger列表;

this.Load + = new EventHandler(FrmRptTrialBalan ceMonthly_Load);

this.FormClosing + = new FormClosingEventHandler(FrmRptTrialBalanceMonthly_FormClosing);

this.btnPrint.Click + = new EventHandler(btnPrint_Click);



}

public System.Collections.IEnumerable DataColl

{

get

{

返回fastObjectListView1.FilteredObjects;

}

}

public void GetDataOfCurrentRow(object obj,Dynamic。 ReportEngine.RDL.Row row)

{

Dynamic.ReportEntity.Account.TrialBalance tbl =(Dynamic.ReportEntity.Account.TrialBalance)obj;

row.Data [0] = tbl.Month;

row.Data [1] = tbl.OpeningDr;

row.Data [2] = tbl.OpeningCr ;

row.Data [3] = tbl.TransactionDr;

row.Data [4] = tbl.TransactionCr;



}

void btnPrint_Click(对象发送者,EventArgs e)

{

ShowReportForm (@D:\ DynamicAccounting \Accounting \ New Account \ Ledger.rdl,TestObjectData);

}



private void ShowReportForm(string path,string title)

{

Dynamic.ReportEngine.FrmRptCustomizeReportView frm = new ReportEngine.FrmRptCustomizeReportView();

//frm.iReportData = this;

frm.SourceFile = path;

frm.TabText = title;

frm.Show() ;

}

void FrmRptTrialBalanceMonthly_FormClosing(对象发送者,FormClosingEventArgs e)

{



}



public void LoadDataFromDB()

{

fastObjectListView1.SetObjects(TrialBalan) ceMonthly.getTrailBalance(DateTime.Today,DateTime.Today,2,6));



}

void FrmRptTrialBalanceMonthly_Load(对象发送者,EventArgs e)

{

getterAndSetter();

LoadDataFromDB();

}



private void getterAndSetter()

{

olvMonth.AspectGetter = delegate(object x)

{

if(x是Dynamic.ReportEntity.Account.TrialBalance)

{

return((Dynamic.ReportEntity.Account.TrialBalance)x) .Month;

}

返回;

};



olvOpeningDr.AspectGetter = delegate(object x)

{

if(x is Dynamic.ReportEntity.Account.TrialBalance)

{

return((Dynamic.ReportEntity.Account.TrialBalance)x).OpeningDr;

}

返回;

};



olvOpeningCr.AspectGetter = delegate(object x)

{

if(x is Dynamic.ReportEntity.Account.TrialBalance) )

{

return((Dynamic.ReportEntity.Account.TrialBalance)x).OpeningCr;

}

返回;

};



olvTransactionDr.AspectGetter =委托(对象x)

{

if(x是Dynamic.ReportEntity.Account.TrialBalance)

{

return((Dynamic.ReportEntity.Account.TrialBalance)x)。 TransactionDr;

}

返回;

};



olvTransactionCr.AspectGetter = delegate(object x)

{

if(x is Dynamic.ReportEntity.Account.TrialBalance)

{

return((Dynamic.ReportEntity.Account.TrialBalance)x)。TransactionCr;

}

return ;

};





}



private void FrmRptTrialBalanceMonthly_Load_1(object sender,EventArgs e)



{



}

}

}



解决方案

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Dynamic.Account.Report.Transaction
{
public partial class FrmRptTrialBalanceMonthly : Form//FrmReportBaseForm<dynamic.reportentity.account.trialbalance>
{
Dynamic.Reporting.Account.TrialBalanceSheetMonthly TrialBalanceMonthly = new Dynamic.Reporting.Account.TrialBalanceSheetMonthly();
public FrmRptTrialBalanceMonthly()
{
InitializeComponent();

System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
this.TabText = "List of Ledger";
this.Load += new EventHandler(FrmRptTrialBalanceMonthly_Load);
this.FormClosing += new FormClosingEventHandler(FrmRptTrialBalanceMonthly_FormClosing);
this.btnPrint.Click += new EventHandler(btnPrint_Click);

}
public System.Collections.IEnumerable DataColl
{
get
{
return fastObjectListView1.FilteredObjects;
}
}
public void GetDataOfCurrentRow(object obj, Dynamic.ReportEngine.RDL.Row row)
{
Dynamic.ReportEntity.Account.TrialBalance tbl = (Dynamic.ReportEntity.Account.TrialBalance)obj;
row.Data[0] = tbl.Month;
row.Data[1] = tbl.OpeningDr;
row.Data[2] = tbl.OpeningCr;
row.Data[3] = tbl.TransactionDr;
row.Data[4] = tbl.TransactionCr;

}
void btnPrint_Click(object sender, EventArgs e)
{
ShowReportForm(@"D:\DynamicAccounting\Accounting\New Account\Ledger.rdl", "TestObjectData");
}

private void ShowReportForm(string path, string title)
{
Dynamic.ReportEngine.FrmRptCustomizeReportView frm = new ReportEngine.FrmRptCustomizeReportView();
//frm.iReportData = this;
frm.SourceFile = path;
frm.TabText = title;
frm.Show();
}
void FrmRptTrialBalanceMonthly_FormClosing(object sender, FormClosingEventArgs e)
{

}

public void LoadDataFromDB()
{
fastObjectListView1.SetObjects(TrialBalanceMonthly.getTrailBalance(DateTime.Today, DateTime.Today,2,6));

}
void FrmRptTrialBalanceMonthly_Load(object sender, EventArgs e)
{
getterAndSetter();
LoadDataFromDB();
}

private void getterAndSetter()
{
olvMonth.AspectGetter = delegate(object x)
{
if (x is Dynamic.ReportEntity.Account.TrialBalance)
{
return ((Dynamic.ReportEntity.Account.TrialBalance)x).Month;
}
return "";
};

olvOpeningDr.AspectGetter = delegate(object x)
{
if (x is Dynamic.ReportEntity.Account.TrialBalance)
{
return ((Dynamic.ReportEntity.Account.TrialBalance)x).OpeningDr;
}
return "";
};

olvOpeningCr.AspectGetter = delegate(object x)
{
if (x is Dynamic.ReportEntity.Account.TrialBalance)
{
return ((Dynamic.ReportEntity.Account.TrialBalance)x).OpeningCr;
}
return "";
};

olvTransactionDr.AspectGetter = delegate(object x)
{
if (x is Dynamic.ReportEntity.Account.TrialBalance)
{
return ((Dynamic.ReportEntity.Account.TrialBalance)x).TransactionDr;
}
return "";
};

olvTransactionCr.AspectGetter = delegate(object x)
{
if (x is Dynamic.ReportEntity.Account.TrialBalance)
{
return ((Dynamic.ReportEntity.Account.TrialBalance)x).TransactionCr;
}
return "";
};


}

private void FrmRptTrialBalanceMonthly_Load_1(object sender, EventArgs e)

{

}
}
}

解决方案

这篇关于如何在C#Dot Net中显示从Sql到Combobox的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 20:23