2011年4月7日木曜日

DataGridViewで2つのグリッドを連動させてスクロールするには?

'----------------------------------------------------------------------------------------------


'スクロール時に2つのグリッドを連動して動かす

'----------------------------------------------------------------------------------------------

Private Sub DataGridView1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles DataGridView1.Scroll

'カラム ※あまり効果ない

Me.DataGridView2.FirstDisplayedScrollingColumnIndex = Me.DataGridView1.FirstDisplayedScrollingColumnIndex

'カラム

Me.DataGridView2.HorizontalScrollingOffset = Me.DataGridView1.HorizontalScrollingOffset

'行

Me.DataGridView2.FirstDisplayedScrollingRowIndex = Me.DataGridView1.FirstDisplayedScrollingRowIndex

End Sub

2011年2月20日日曜日

HashTableカンマキー

Dim ht As New Hashtable




ht.Add("", "1")

ht.Add("BBB,222", "2")

ht.Add("CCC,333", "3")

ht.Add("DDD,444", "4")



'キーが含まれているか確認

If ht.ContainsKey("DDD,444") Then

'数値インクリメント

'値の数値判定

If IsNumeric(ht("DDD,444")) Then

Dim index As Integer = CInt(ht("DDD,444")) + 1

ht("DDD,444") = index

End If

Else

'含まれていなければ追加

ht.Add("DDD,444", "1")

End If



'キーの数だけループ

Dim strKeysVal() As String

For Each strKey As String In ht.Keys

'コンマで分割

strKeysVal = strKey.Split(",")

'キーの配列長さ判定

If strKeysVal.Length > 1 Then

'値の数値判定

If IsNumeric(ht(strKey)) Then

Dim index As Integer = CInt(ht(strKey))



End If

End If

Next

2011年2月5日土曜日

マルチグリッドサンプル

http://www.4shared.com/file/cmyWDrnq/DataGridMultiHead.html

Word.Applicationが使用できない 使用方法

Office PIAs の 参照の場所が間違っていると考えられます。
例)
C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Office.dll

2011年1月29日土曜日

データグリッドでセル結合を実現

データグリッドでセルが結合できないのは意外と不便に感じるものです、

そんな時にはDataGridViewForMergeコンポーネントを是非ご活用されてみてはいかがでしょうか。

セル結合コンポDataGridViewForMergeダウンロードできます。






Grid(グリッド)でセルを結合したい時などに便利なコンポーネントです。

DataGridやDataGridViewで実現可能

merge0.jpg



複数セルの結合も可能です。

merge1.jpg



利用してみたいという方は、

Vector(ベクター)からダウンロードできます。




【サンプルソースはこちら】

'初期化

Me.DataGridViewForMerge1.MergeCellDataList.Clear()

'==================================

'詳細設定サンプル

'==================================

'----------------------------------

'Rowヘッダー作成

'----------------------------------

For rowIndex As Integer = 0 To 5

Me.DataGridViewForMerge1.Rows(rowIndex).Cells(0).Value = "予定" & rowIndex.ToString("000")

Me.DataGridViewForMerge1.Rows(rowIndex).Cells(0).Style.BackColor = Color.Gray

Next



'-----------------------------------

'Colヘッダー作成

'-----------------------------------

For colIndex As Integer = 1 To 31

Me.DataGridViewForMerge1.Columns(colIndex).HeaderText = colIndex.ToString("000")

Me.DataGridViewForMerge1.Columns(colIndex).Width = 50

Next



'-----------------------------------

'結合処理

'-----------------------------------

'結合クラス作成

Dim mergeCellClass As MergeCellData

mergeCellClass = New MergeCellData

'開始行

mergeCellClass.StartRow = 0

'開始列

mergeCellClass.StartCol = 1

'終了行

mergeCellClass.EndRow = 0

'終了列

mergeCellClass.EndCol = 3

'色指定

mergeCellClass.BackColor = Color.Red

'登録

Me.DataGridViewForMerge1.MergeCellDataList.Add(mergeCellClass)

'------------------------------------

mergeCellClass = New MergeCellData

'開始行

mergeCellClass.StartRow = 1

'開始列

mergeCellClass.StartCol = 2

'終了行

mergeCellClass.EndRow = 1

'終了列

mergeCellClass.EndCol = 4

'色指定

mergeCellClass.BackColor = Color.Blue

'登録

Me.DataGridViewForMerge1.MergeCellDataList.Add(mergeCellClass)

'------------------------------------

mergeCellClass = New MergeCellData

'開始行

mergeCellClass.StartRow = 2

'開始列

mergeCellClass.StartCol = 4

'終了行

mergeCellClass.EndRow = 2

'終了列

mergeCellClass.EndCol = 6

'色指定

mergeCellClass.BackColor = Color.Green

'登録

Me.DataGridViewForMerge1.MergeCellDataList.Add(mergeCellClass)

'------------------------------------

mergeCellClass = New MergeCellData

'開始行

mergeCellClass.StartRow = 3

'開始列

mergeCellClass.StartCol = 1

'終了行

mergeCellClass.EndRow = 3

'終了列

mergeCellClass.EndCol = 4

'色指定

mergeCellClass.BackColor = Color.Yellow

'登録

Me.DataGridViewForMerge1.MergeCellDataList.Add(mergeCellClass)

'------------------------------------

mergeCellClass = New MergeCellData

'開始行

mergeCellClass.StartRow = 4

'開始列

mergeCellClass.StartCol = 1

'終了行

mergeCellClass.EndRow = 4

'終了列

mergeCellClass.EndCol = 9

'色指定

mergeCellClass.BackColor = Color.Blue

'登録

Me.DataGridViewForMerge1.MergeCellDataList.Add(mergeCellClass)



'描画する

Me.DataGridViewForMerge1.Refresh()

2011年1月27日木曜日

DataGridでセルを結合できるコンポーネントVB

MSFlexGridのようにセルを結合できるコンポーネントの紹介



ダウンロードはこちらで公開されています⇒Vector(ベクター)
1、結合はこんな感じになります。





2、複数のセル結合は表を作るのに最適





ダウンロードはこちらで公開されています⇒Vector(ベクター)

2011年1月26日水曜日

DataGridでセル(Cell)を結合(Merge)する方法

Grid(グリッド)でセルを結合したい時などに便利なコンポーネントです。


Vector(ベクター)からダウンロードできます。 DataGridやDataGridViewで実現可能 merge0.jpg


複数セルの結合も可能です。


merge1.jpg


利用してみたいという方は、 Vector(ベクター)からダウンロードできます。