VB 指定年月の最終日を取得
Public Function GetLastDayOfMonth(intMonth, intYear) As Date
Return DateSerial(intYear, intMonth + 1, 0)
End Function
2013年4月25日木曜日
2013年4月17日水曜日
Vb DataGridView フォーカスを示す四角形点線枠を消す方法
Vb DataGridView フォーカスを示す四角形点線枠を消す方法
1. CellPaintingイベントハンドラで自分で枠を描くように
'CellPaintingイベントハンドラ
2.DataGridViewのShowFocusCuesをオーバーライドし、常にfalseを返すように
public class DatagridViewGS : DatagridView
{
protected override bool ShowFocusCues
{
get { return false; }
}
}
1. CellPaintingイベントハンドラで自分で枠を描くように
'CellPaintingイベントハンドラ
Private Sub DataGridView1_CellPainting(ByVal sender As Object, _ ByVal e As DataGridViewCellPaintingEventArgs) _ Handles DataGridView1.CellPainting 'ヘッダー以外のとき If e.ColumnIndex >= 0 And e.RowIndex >= 0 Then 'フォーカス枠以外が描画されるようにする Dim paintParts As DataGridViewPaintParts = _ e.PaintParts And Not DataGridViewPaintParts.Focus 'セルを描画する e.Paint(e.ClipBounds, paintParts) '描画が完了したことを知らせる e.Handled = True End If End Sub参考URL
2.DataGridViewのShowFocusCuesをオーバーライドし、常にfalseを返すように
public class DatagridViewGS : DatagridView
{
protected override bool ShowFocusCues
{
get { return false; }
}
}
2013年4月12日金曜日
vb DataTable.Clear と DataTable.Rows.Clear. の違い
vb DataTable.Clear と DataTable.Rows.Clear. の違い
古い.Net 1.1バージョン、同じだったらしい。 DataRowCollection.Clearの処理の中、DataTable.Clearを呼び出す。
.Net 2.0違は違います。
参考:In .Net 1.1,
古い.Net 1.1バージョン、同じだったらしい。 DataRowCollection.Clearの処理の中、DataTable.Clearを呼び出す。
.Net 2.0違は違います。
参考:In .Net 1.1,
DataRowCollection.Clear calls DataTable.Clear
However, in .Net 2.0, there is a difference. If I understand the source correctly,
DataTable.Clear will clear unattached rows (created using DataTable.NewRow) whereas DataRowCollection.Clear won't.
The difference is in
RecordManager.Clear (source below, from the .Net Reference Source for v3.5 SP 0); clearAll is true only when called from DataTable.Clear. internal void Clear(bool clearAll) {
if (clearAll) {
for(int record = 0; record < recordCapacity; ++record) {
rows[record] = null;
}
int count = table.columnCollection.Count;
for(int i = 0; i < count; ++i) {
//
DataColumn column = table.columnCollection[i];
for(int record = 0; record < recordCapacity; ++record) {
column.FreeRecord(record);
}
}
lastFreeRecord = 0;
freeRecordList.Clear();
}
else { // just clear attached rows
freeRecordList.Capacity = freeRecordList.Count + table.Rows.Count;
for(int record = 0; record < recordCapacity; ++record) {
if (rows[record]!= null && rows[record].rowID != -1) {
int tempRecord = record;
FreeRecord(ref tempRecord);
}
}
}
}
登録:
コメント (Atom)