C
chh.552
Guest
1. I created a view and made the bound data appear in the view through the package call.
2. I want to rearrange the rows of data in the view.
ex) value -> value
up up
down left
left down
right right
3. Now, as I expected, I think dragging is not going through the rows. I've tried drag and drop in the behavior manager, but I can not help it.
gridcontrol->grdProgramStdInfo ,,gridview->grvProgramStdInfo !
GridHitInfo downHitInfo = null;
private void gridControl_MouseDown(object sender, MouseEventArgs e)
{
GridView view = sender as GridView;
downHitInfo = null;
GridHitInfo hitInfo = view.CalcHitInfo(new Point(e.X, e.Y));
if (Control.ModifierKeys != Keys.None) return;
if (e.Button == MouseButtons.Left && hitInfo.RowHandle >= 0)
downHitInfo = hitInfo;
}
private void gridControl_MouseMove(object sender, MouseEventArgs e)
{
GridView view = sender as GridView;
if (e.Button == MouseButtons.Left && downHitInfo != null)
{
Size dragSize = SystemInformation.DragSize;
Rectangle dragRect = new Rectangle(new Point(downHitInfo.HitPoint.X - dragSize.Width / 2,
downHitInfo.HitPoint.Y - dragSize.Height / 2), dragSize);
if (!dragRect.Contains(new Point(e.X, e.Y)))
{
DataRow row = view.GetDataRow(downHitInfo.RowHandle);
view.GridControl.DoDragDrop(row, DragDropEffects.Move);
downHitInfo = null;
DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = true;
}
}
}
private void gridControl_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(DataRow)))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
}
private void gridControl_DragDrop(object sender, DragEventArgs e)
{
GridControl grid = sender as GridControl;
DataTable table = grid.DataSource as DataTable;
DataRow row = e.Data.GetData(typeof(DataRow)) as DataRow;
if (row != null && table != null && row.Table != table)
{
table.ImportRow(row);
row.Delete();
}
}
private void dragDropEvents1_DragDrop(object sender, DragDropEventArgs e)
{
}
private void dragDropEvents1_DragOver(object sender, DragOverEventArgs e)
{
DragOverGridEventArgs args = DragOverGridEventArgs.GetDragOverGridEventArgs(e);
e.InsertType = args.InsertType;
e.InsertIndicatorLocation = args.InsertIndicatorLocation;
e.Action = args.Action;
Cursor.Current = args.Cursor;
args.Handled = true;
}
this.grdProgramStdInfo.DragDrop += new System.Windows.Forms.DragEventHandler(this.gridControl_DragDrop);
this.grdProgramStdInfo.DragOver += new System.Windows.Forms.DragEventHandler(this.gridControl_DragOver);
this.grvProgramStdInfo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.gridControl_MouseDown);
this.grvProgramStdInfo.MouseMove += new System.Windows.Forms.MouseEventHandler(this.gridControl_MouseMove
Continue reading...
2. I want to rearrange the rows of data in the view.
ex) value -> value
up up
down left
left down
right right
3. Now, as I expected, I think dragging is not going through the rows. I've tried drag and drop in the behavior manager, but I can not help it.
gridcontrol->grdProgramStdInfo ,,gridview->grvProgramStdInfo !
GridHitInfo downHitInfo = null;
private void gridControl_MouseDown(object sender, MouseEventArgs e)
{
GridView view = sender as GridView;
downHitInfo = null;
GridHitInfo hitInfo = view.CalcHitInfo(new Point(e.X, e.Y));
if (Control.ModifierKeys != Keys.None) return;
if (e.Button == MouseButtons.Left && hitInfo.RowHandle >= 0)
downHitInfo = hitInfo;
}
private void gridControl_MouseMove(object sender, MouseEventArgs e)
{
GridView view = sender as GridView;
if (e.Button == MouseButtons.Left && downHitInfo != null)
{
Size dragSize = SystemInformation.DragSize;
Rectangle dragRect = new Rectangle(new Point(downHitInfo.HitPoint.X - dragSize.Width / 2,
downHitInfo.HitPoint.Y - dragSize.Height / 2), dragSize);
if (!dragRect.Contains(new Point(e.X, e.Y)))
{
DataRow row = view.GetDataRow(downHitInfo.RowHandle);
view.GridControl.DoDragDrop(row, DragDropEffects.Move);
downHitInfo = null;
DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = true;
}
}
}
private void gridControl_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(DataRow)))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
}
private void gridControl_DragDrop(object sender, DragEventArgs e)
{
GridControl grid = sender as GridControl;
DataTable table = grid.DataSource as DataTable;
DataRow row = e.Data.GetData(typeof(DataRow)) as DataRow;
if (row != null && table != null && row.Table != table)
{
table.ImportRow(row);
row.Delete();
}
}
private void dragDropEvents1_DragDrop(object sender, DragDropEventArgs e)
{
}
private void dragDropEvents1_DragOver(object sender, DragOverEventArgs e)
{
DragOverGridEventArgs args = DragOverGridEventArgs.GetDragOverGridEventArgs(e);
e.InsertType = args.InsertType;
e.InsertIndicatorLocation = args.InsertIndicatorLocation;
e.Action = args.Action;
Cursor.Current = args.Cursor;
args.Handled = true;
}
this.grdProgramStdInfo.DragDrop += new System.Windows.Forms.DragEventHandler(this.gridControl_DragDrop);
this.grdProgramStdInfo.DragOver += new System.Windows.Forms.DragEventHandler(this.gridControl_DragOver);
this.grvProgramStdInfo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.gridControl_MouseDown);
this.grvProgramStdInfo.MouseMove += new System.Windows.Forms.MouseEventHandler(this.gridControl_MouseMove
Continue reading...