C1FlexGrid 拖拽
1.FlexGrid的DropMode=Manual
1 private void fgMain_DragDrop(object sender, DragEventArgs e) 2 { 3 int row = this.fgMain.MouseRow; 4 int col = this.fgMain.MouseCol; 5 6 if (row < 1 || col < 1 || col % 2 == 0) 7 { 8 return; 9 } 10 11 try 12 { 13 Cursor = Cursors.WaitCursor; 14 15 // DB初期化 16 Common.DB_Init(Common.sCn); 17 18 if (e.Data.GetDataPresent(DataFormats.Text)) 19 { 20 // 移動元のデータ 21 string data = e.Data.GetData(DataFormats.Text).ToString(); 22 this.fgMain.Rows[row][col] = data; 23 24 // 品名の検索 25 string shobunruiCD = this.fgMain.Rows[1][col] == null ? "" : this.fgMain.Rows[1][col].ToString().Trim(); 26 string saibunruiCD = data; 27 this.fgMain.Rows[row][col + 1] = modSeihinKikakusyo.fnc色名取得(shobunruiCD, data); 28 } 29 } 30 catch (Exception ex) 31 { 32 // エラー発生の場合 33 strMessage = Msg.GetMessageInfo("MSPJ0001", "\n" + ex.Message.ToString()); 34 MessageBox.Show(strMessage, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); 35 } 36 finally 37 { 38 // DBアクセスのリソース開放 39 Common.DB_End(); 40 41 Cursor = Cursors.Default; 42 } 43 } 44 45 private void fgMain_DragEnter(object sender, DragEventArgs e) 46 { 47 if (e.Data.GetDataPresent(DataFormats.Text)) 48 { 49 e.Effect = DragDropEffects.Copy; 50 } 51 else 52 { 53 e.Effect = DragDropEffects.None; 54 } 55 }