Dim lngIndex As Long
Dim lngRow As Long
With MSHFlexGrid1
.Rows = 13
.Cols = 15
.MergeCells = flexMergeFree '?????????
.TextMatrix(0, 0) = "拟晋升专业"
.TextMatrix(1, 0) = "拟晋升专业"
For lngIndex = 1 To 6
.TextMatrix(0, lngIndex) = "拟晋升职称级别"
Next
.TextMatrix(1, 1) = "小计"
.TextMatrix(1, 2) = "正高"
.TextMatrix(1, 3) = "副高"
.TextMatrix(1, 4) = "中级"
.TextMatrix(1, 5) = "助师级"
.TextMatrix(1, 6) = "员级"
For lngIndex = 7 To 11
.TextMatrix(0, lngIndex) = "晋 升 方 式"
Next
.TextMatrix(1, 7) = "正常晋升"
.TextMatrix(1, 8) = "学历破格"
.TextMatrix(1, 9) = "年限破格"
.TextMatrix(1, 10) = "学历年限破格"
.TextMatrix(1, 11) = "其他"
.TextMatrix(0, 12) = "联系人"
.TextMatrix(1, 12) = "联系人"
.TextMatrix(0, 13) = "联系电话"
.TextMatrix(1, 13) = "联系电话"
.TextMatrix(0, 14) = "备注"
.TextMatrix(1, 14) = "备注"
'
.MergeRow(0) = True
.MergeCol(0) = True
.MergeCol(12) = True
.MergeCol(13) = True
.MergeCol(14) = True
For lngRow = 0 To 1
For lngIndex = 0 To 14
.Row = lngRow
.Col = lngIndex
.CellAlignment = flexAlignCenterCenter
.ColAlignment(lngIndex) = flexAlignCenterCenter
Next
Next
'' .RowHeight(0) = 0
' .ColWidth(0) = 1800
' For lngIndex = 1 To 6
' .ColWidth(lngIndex) = 600
' Next
' For lngIndex = 7 To 11
' .ColWidth(lngIndex) = 1000
' Next
' .ColWidth(12) = 1000
' .ColWidth(13) = 1600
' .ColWidth(14) = 1600
End With见与在VS2005中的WINFORM中的DATAGRIEVIEW的表头没有合并的功能,同样可以把VB6中的着个控件添加进来
,实现同样的效果,下面是在VS2005中的C#实现合并功能的代码
long lngIndex;
long lngRow;
axMSHFlexGrid1.Rows=3;
axMSHFlexGrid1.FixedRows = 2;
axMSHFlexGrid1.set_RowHeight(0, 400);
axMSHFlexGrid1.set_RowHeight(1, 300);
axMSHFlexGrid1.set_Cols(15);
axMSHFlexGrid1.MergeCells = MSHierarchicalFlexGridLib.MergeCellsSettings.flexMergeFree; // '?????????
axMSHFlexGrid1.set_TextMatrix(0, 0,"项目");
axMSHFlexGrid1.set_TextMatrix(1, 0, "项目");
axMSHFlexGrid1.set_TextMatrix(0, 1, "单位");
axMSHFlexGrid1.set_TextMatrix(1, 1, "单位");
axMSHFlexGrid1.set_TextMatrix(0, 2, "年计划");
axMSHFlexGrid1.set_TextMatrix(1, 2, "年计划");

for(lngIndex = 3;lngIndex<9;lngIndex++)
...{
axMSHFlexGrid1.set_TextMatrix(0, (int)lngIndex,"实际完成");
}
axMSHFlexGrid1.set_TextMatrix(1, 3, "报表反映");
axMSHFlexGrid1.set_TextMatrix(1, 4, "人员买断及财产损失");
axMSHFlexGrid1.set_TextMatrix(1, 5, "经营实级");
axMSHFlexGrid1.set_TextMatrix(1, 6, "上年同期");
axMSHFlexGrid1.set_TextMatrix(1, 7, "同比增减");
axMSHFlexGrid1.set_TextMatrix(1, 8, "增件率(%)");
for(lngIndex = 9;lngIndex<14;lngIndex++)
...{
axMSHFlexGrid1.set_TextMatrix(0, (int)lngIndex,"箱平担平(元)");
}
axMSHFlexGrid1.set_TextMatrix(1, 9, "本年实际");
axMSHFlexGrid1.set_TextMatrix(1, 10, "年计划");
axMSHFlexGrid1.set_TextMatrix(1, 11, "与计划比增减");
axMSHFlexGrid1.set_TextMatrix(1, 12,"上年同期");
axMSHFlexGrid1.set_TextMatrix(1, 13,"同比增减(+ -)");
//axMSHFlexGrid1.set_TextMatrix(0, 12,"联系人");
//axMSHFlexGrid1.set_TextMatrix(1, 12,"联系人");
//axMSHFlexGrid1.set_TextMatrix(0, 13,"联系电话");
//axMSHFlexGrid1.set_TextMatrix(1, 13,"联系电话");
//axMSHFlexGrid1.set_TextMatrix(0, 14,"备注");
axMSHFlexGrid1.set_TextMatrix(0, 14, "完成年计划(%)");
axMSHFlexGrid1.set_TextMatrix(1, 14, "完成年计划(%)");
axMSHFlexGrid1.set_MergeRow(0,true);
axMSHFlexGrid1.set_MergeCol(0, true);
//axMSHFlexGrid1.set_MergeRow(1, true);
axMSHFlexGrid1.set_MergeCol(1, true);
//axMSHFlexGrid1.set_MergeRow(2, true);
axMSHFlexGrid1.set_MergeCol(2, true);
axMSHFlexGrid1.set_MergeCol(13, true);
axMSHFlexGrid1.set_MergeCol(14,true);
//for (lngRow = 0; lngRow < 2; lngRow++)
//{
// for( lngIndex = 0;lngIndex<15;lngIndex++)
// {
// axMSHFlexGrid1.Row = (int)lngRow;
// axMSHFlexGrid1.set_Cols((int)lngIndex);
// // axMSHFlexGrid1.CellAlignment = MSHierarchicalFlexGridLib.AlignmentSettings.flexAlignCenterCenter;
// // axMSHFlexGrid1.CellAlignment = 2;
// //axMSHFlexGrid1.set_FixedAlignment((int)lngIndex,2);
// //axMSHFlexGrid1.set_FixedAlignment((int)lngIndex, MSHierarchicalFlexGridLib.AlignmentSettings.flexAlignCenterCenter);
// }
//}
/**//* .RowHeight(0) = 0
// .ColWidth(0) = 1800
// For lngIndex = 1 To 6
// .ColWidth(lngIndex) = 600
// Next
' For lngIndex = 7 To 11
' .ColWidth(lngIndex) = 1000
' Next
' .ColWidth(12) = 1000
' .ColWidth(13) = 1600
' .ColWidth(14) = 1600*/