private void Button1_Click(object sender, System.EventArgs e)
{
if(this.UltraWebGrid1.DisplayLayout.SelectedCells.Count>0)
{
//create variables to hold the min/max column and row
int colMin =this.UltraWebGrid1.DisplayLayout.SelectedCells[0].Column.Index;
int colMax = this.UltraWebGrid1.DisplayLayout.SelectedCells[0].Column.Index;
int rowMin = this.UltraWebGrid1.DisplayLayout.SelectedCells[0].Row.Index;
int rowMax = this.UltraWebGrid1.DisplayLayout.SelectedCells[0].Row.Index;
//determine the min/max column and row
foreach(UltraGridCell aCell in this.UltraWebGrid1.DisplayLayout.SelectedCells)
{
if(aCell.Column.Index < colMin)
colMin=aCell.Column.Index;
if(aCell.Column.Index > colMax)
colMax=aCell.Column.Index;
if(aCell.Row.Index < rowMin)
rowMin=aCell.Row.Index;
if(aCell.Row.Index > rowMax)
rowMax=aCell.Row.Index; }
//get a reference to the top left most cell to use for the merge
UltraGridCell cell=this.UltraWebGrid1.Rows[rowMin].Cells[colMin];
//deactivate the current activecell
cell.Activated=false;
//create a variable to control the loop for the selected cells
// you must get this now because as you deselect cells the count decreases
// so if you use for(short i=0;i<selectedCells.count; i++) then the loop will
//will exit prematurely since selectedCell.count will be decreasing inside the loop
//deselect the currently selected cells
int x=this.UltraWebGrid1.DisplayLayout.SelectedCells.Count;
for(short i=0;i<x; i++)
this.UltraWebGrid1.DisplayLayout.SelectedCells[this.UltraWebGrid1.DisplayLayout.SelectedCells.Count-1].Selected=false;
// set the col span and row span based upon the min/max column and row
cell.ColSpan=colMax-colMin+1;
cell.RowSpan=rowMax-rowMin+1;
//get a reference to the row
UltraGridRow row=cell.Row;
//set the merged cell at the coluymn index of the top/left most cell
//set an image for the merged cell
cell.Style.BackgroundImage="image/ig_logo.gif";
cell.Style.CustomRules="background-repeat:no-repeat;background-position:center center;";
cell.Text = "";
//set thge new merged cell as active
this.UltraWebGrid1.DisplayLayout.ActiveCell=cell; }
}
{
if(this.UltraWebGrid1.DisplayLayout.SelectedCells.Count>0)
{
//create variables to hold the min/max column and row
int colMin =this.UltraWebGrid1.DisplayLayout.SelectedCells[0].Column.Index;
int colMax = this.UltraWebGrid1.DisplayLayout.SelectedCells[0].Column.Index;
int rowMin = this.UltraWebGrid1.DisplayLayout.SelectedCells[0].Row.Index;
int rowMax = this.UltraWebGrid1.DisplayLayout.SelectedCells[0].Row.Index;
//determine the min/max column and row
foreach(UltraGridCell aCell in this.UltraWebGrid1.DisplayLayout.SelectedCells)
{
if(aCell.Column.Index < colMin)
colMin=aCell.Column.Index;
if(aCell.Column.Index > colMax)
colMax=aCell.Column.Index;
if(aCell.Row.Index < rowMin)
rowMin=aCell.Row.Index;
if(aCell.Row.Index > rowMax)
rowMax=aCell.Row.Index; }
//get a reference to the top left most cell to use for the merge
UltraGridCell cell=this.UltraWebGrid1.Rows[rowMin].Cells[colMin];
//deactivate the current activecell
cell.Activated=false;
//create a variable to control the loop for the selected cells
// you must get this now because as you deselect cells the count decreases
// so if you use for(short i=0;i<selectedCells.count; i++) then the loop will
//will exit prematurely since selectedCell.count will be decreasing inside the loop
//deselect the currently selected cells
int x=this.UltraWebGrid1.DisplayLayout.SelectedCells.Count;
for(short i=0;i<x; i++)
this.UltraWebGrid1.DisplayLayout.SelectedCells[this.UltraWebGrid1.DisplayLayout.SelectedCells.Count-1].Selected=false;
// set the col span and row span based upon the min/max column and row
cell.ColSpan=colMax-colMin+1;
cell.RowSpan=rowMax-rowMin+1;
//get a reference to the row
UltraGridRow row=cell.Row;
//set the merged cell at the coluymn index of the top/left most cell
//set an image for the merged cell
cell.Style.BackgroundImage="image/ig_logo.gif";
cell.Style.CustomRules="background-repeat:no-repeat;background-position:center center;";
cell.Text = "";
//set thge new merged cell as active
this.UltraWebGrid1.DisplayLayout.ActiveCell=cell; }
}
解决方案 »
- log4net具体怎么用啊?怎么这么迷糊呢?
- C# WINDOWS FORM,多语言办法。
- 奇怪的正则,关于百分号的处理异常
- (B/S)关于TreeView的用法
- 静态函数
- 我通过逐像素比较两幅图象,但是不知道应该怎样强调两幅图象不同的地方,大家给个建议啊
- 1.0 is not float (新手问题)
- 能通俗的讲一下C#中的事件吗?看了两本书上这方面知识点也没有能弄多大明白。谢谢
- Socket编程问题,为什么TcpListener一不小心就把程序就死掉了?
- 请问C#可以开发组件,在Web上可以出现象ActiveX的窗体吗?那么是不是VC开发web的ActiveX今后应当换成.net开发更快更简单?
- c#能写asp的组件吗。
- 求.NET Remoteing工作方式
http://www.csdn.net/develop/Read_Article.asp?Id=24441
http://www.csdn.net/develop/Read_Article.asp?Id=24432
你上面写的代码是不是有遗漏的地方, 你能不能留下联系方式,我想向你请教一下。