Farpoint Spread 2005 的一些用法

FpSpread命名﹕sgrid1

1. 設置表格行列標題的背景顏色

sgrid1_Sheet1.RowHeader.DefaultStyle.BackColor =

Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));


sgrid1_Sheet1.ColumnHeader.DefaultStyle.BackColor =

Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));


sgrid1_Sheet1.SheetCornerStyle.BackColor =

Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));

 

 2. 設置列的樣式

//將第一列設置成設置成"選擇框"

sgrid1.Sheets[0].Columns[0].CellType

= new FarPoint.Win.Spread.CellType.CheckBoxCellType();

//"選擇框"居中
sgrid1.Sheets[0].Columns[0].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;

 

//將第一列設置成設置成"組合下拉框",并填充值

 

DataSet ds = new DataSet();
string sql = "";            
string str = "";
string[] strItem;

 

 sql = "Select Status_Descc From A_OrderStatus with(nolock) ";
 ds = ; //獲取 dataset 至于如何填充ds﹐這里就不寫了
 strItem = new string[ds.Tables[0].Rows.Count];  //數組長度
 foreach (DataRow dr in ds.Tables[0].Rows)
            {
                str = str + dr["Status_Desc"].ToString().Trim() + ",";
            }
 strItem = str.Split(new char[1] { ',' });
 FarPoint.Win.Spread.CellType.ComboBoxCellType cb =

 new FarPoint.Win.Spread.CellType.ComboBoxCellType();
 

 cb.Items = strItem;
 sgrid1.Sheets[0].Columns[(int)V1.status_descc].CellType = cb;

 

 

 

3.鼠標點擊時整行選擇

sgrid1.ActiveSheet.SelectionUnit = FarPoint.Win.Spread.Model.SelectionUnit.Row;

 

4.按回車時 FarSpread 默認是不移動的﹐我們一般需要向右移動

   需要這樣設置﹕

FarPoint.Win.Spread.InputMap im;
im = sgrid1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
           

im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None),

 FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap);
           

im = sgrid1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
           

im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap);

 

5. 

 

 

你可能感兴趣的:(sql,String,byte,IM,dataset)