多多关注啊。。。。。。请高手们帮帮忙。 关于TreeView的。 当TreeView执行拖拽事件, 有什么办法使状态能像Windows的文件夹那样, 无论何时按住Ctrl键就会变成copy状态, 放开Ctrl键就变成move状态。 我按照MSDN上的例子试验了很多次, 每一次把effect改变, 值虽然是改变了, 但它的状态就变成none,弄的小弟好郁闷。如果有这方面经验的朋友请顶一下。 谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可否考虑动态捕捉CTRL键,参考:protected void Edit_KeyDown(object sender, KeyEventArgs e){ if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right ) return; else { if(e.Control ) { if(e.KeyCode ==Keys.C) { e.Handled = true; this.CopyClipBoard(); } if(e.KeyCode ==Keys.V ) { e.Handled = true; this.PasteClipBoard(); } 你所说的MSDN的例子在哪里?能不能把你拖动的那部分代码贴出来看看? private void treeView_MyPre_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { // Retrieve the client coordinates of the mouse position. Point targetPoint = treeView_MyPre.PointToClient(new Point(e.X, e.Y)); // Select the node at the mouse position. treeView_MyPre.SelectedNode = treeView_MyPre.GetNodeAt(targetPoint); if ((e.KeyState & 8) == 8 )//&& //(e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) { // CTL KeyState for copy. e.Effect = DragDropEffects.Copy; } else //if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) { // By default, the drop action should be move, if allowed. e.Effect = DragDropEffects.Move; } } 上面就是我的代码, 当移动拖拽中碰触其他TreeNode,就判断Ctrl键是否按下了。 可是在改变效果时,如果原来是Move状态, 改变为Copy状态时, 就不可以。 为什么啊。 并不是因为不能获知Ctrl键是否按下的原因, 是因为改变拖拽状态时不起作用。请高手快点帮忙啊!!!!!!!! 可以的啊。你有没有犯一个低级错误:你的treeview的AllowDrop设为true了吗? 只是在拖拽时无法从copy改变为move, 相反也是。 com组件奇怪的问题 转化为xml的问题 使用WebValidates.dll生成验证码,如何控制生成字符的个数? 关于插入数据库时引号问题? c#如何判断字符数组里某个位置是否有值 请问C#如何学习,步骤是怎么样的 用数据库生成多级TreeView菜单的问题 关于控件拖动程序中用到的Offset()方法中偏移量为什么是负的 关于.net的几个问题 如何用HScrollBar操纵PictureBox中的图像? 谢谢各位,办办忙好吗? 我需要做一个系统,想做成象WORD一样的编辑功能,不知要如何才能实现,要求能插入图片和视频,所以不能光用富文本控件。不知那位朋友能给 不知道如何处理这个异常
{
if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right )
return;
else
{
if(e.Control )
{
if(e.KeyCode ==Keys.C)
{
e.Handled = true;
this.CopyClipBoard();
}
if(e.KeyCode ==Keys.V )
{
e.Handled = true;
this.PasteClipBoard();
}
能不能把你拖动的那部分代码贴出来看看?
{
// Retrieve the client coordinates of the mouse position.
Point targetPoint = treeView_MyPre.PointToClient(new Point(e.X, e.Y)); // Select the node at the mouse position.
treeView_MyPre.SelectedNode = treeView_MyPre.GetNodeAt(targetPoint); if ((e.KeyState & 8) == 8 )//&&
//(e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
{
// CTL KeyState for copy.
e.Effect = DragDropEffects.Copy;
}
else //if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)
{
// By default, the drop action should be move, if allowed.
e.Effect = DragDropEffects.Move;
} }