08/04/07 19:48:19
>>675さんのお話を聞くと、自分のコーディングの方向性が
根本的に間違っているような気がしてきました・・・。
ここに書き込む前は、以下のような方法で実現しようとしていました。
namespace下に以下のようなクラスを作成し、
public class CurrentYearAndMonth
{
public static int cYear;
public static int cMonth;
public static int cMonthDaysCount;
public static void SyncYM()
{
DateTime dtNow = DateTime.Now;
cYear = dtNow.Year;
cMonth = dtNow.Month;
cMonthDaysCount = DateTime.DaysInMonth(cYear, cMonth);
}
}
これに対して、グリッドを配置しているFormのForm_Loadメソッド内で、
簡潔に書くと以下のように上記の変数を使っています。
for (int r = 1; r <= CurrentYearAndMonth.cMonthDaysCount; r++)
{
grid1.Rows.Insert(r);
grid1[r, 0] = new SourceGrid.Cells.Cell(CurrentYearAndMonth.cMonth.ToString() + "月" + r.ToString() + "日");
}
この状態で、Load完了後にcMonthなどの変数値をいじってFormやgrid1をUpdate()などしてみると、
UI上の表示も変化するかなと目論んでいたんですが、やはり間違っているのでしょうか?
(ちなみに、SourceGridは
URLリンク(sourceforge.net)
からダウンロードできます。)