Tarihleri Set Edecek Olan Fonksiyon:
public void SetTarih(int pAyId)
{
//ayın ilk gününü dönderen tarih.
txtBaslangicTarihi.DateTime = new DateTime(DateTime.Now.Year, pAyId, 1);
//Ayın son günün dönderen tarih.
txtBitisTarihi.DateTime = new DateTime(DateTime.Now.Year, pAyId, 1).AddMonths(1).AddDays(-1);
}
NOT:
Fonksiyonda pAyId olarak verilen parametre ilgili ayın Id bilgisidir. Bu bilgiye eğer DevExpress kullanıyorsanız "MonthEdit" nesnesini kullanarak elde edebilirsiniz.
Örnek Kullanım:
private void txtDonem_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
{
if (e.NewValue!=null)
{
SetTarih(Convert.ToInt32(e.NewValue));
}
}