Tag: move

将datagridview行移动到另一个datagridView

对于这类问题,我已经完成了其他答案,到目前为止还没有真正奏效。 我有一个foreach循环,它应该将源datagridview的行添加到目标datagridview然后从源中删除该行。 无效的操作exception是: Row provided already belongs to a DataGridView control. 我无法得到…Rows.Copy()也可以。 有任何想法吗? foreach (DataGridViewRow selRow in fromDataGridView.SelectedRows) { toDataGridView.Rows.Add(selRow); fromDataGridView.Rows.Remove(selRow); }

C#表单控件移动

反正有控制你可以移动表格的地方吗? 因此,如果我移动一个表格,它只能在垂直轴上移动,当我尝试水平移动时,没有任何反应。 我不想要像changechanged或move事件那样的bug实现并将其弹回内联。 我没有办法使用类似WndProc覆盖的东西,但在搜索了一段时间后,我找不到任何东西。 请帮忙

System.IO.File.Delete()/ System.IO.File.Move()有时不起作用

Winforms程序需要将一些运行时信息保存到XML文件中。 该文件有时可能是几百千字节。 在beta测试期间,我们发现一些用户会毫不犹豫地随机终止进程并偶尔导致文件被写入一半并因此被破坏。 因此,我们将算法更改为保存到临时文件,然后删除实际文件并执行移动。 我们的代码目前看起来像.. private void Save() { XmlTextWriter streamWriter = null; try { streamWriter = new XmlTextWriter(xmlTempFilePath, System.Text.Encoding.UTF8); XmlSerializer xmlSerializer = new XmlSerializer(typeof(MyCollection)); xmlSerializer.Serialize(streamWriter, myCollection); if (streamWriter != null) streamWriter.Close(); // Delete the original file System.IO.File.Delete(xmlFilePath); // Do a move over the top of the original file System.IO.File.Move(xmlTempFilePath, xmlFilePath); } catch (System.Exception ex) […]

防止用户删除,移动或重命名文件

我想要做的是当我的程序使用文件时,我想让用户不要重命名,删除或移动文件(好吧……根据Windows,移动是删除和创建在不同的位置) FileSystemWatcher ,但我离题了)。 有人建议我使用FileStream.Lock或使用Mutex 。 但是,FileStream.Lock似乎只是为了防止文件被修改,我试图允许 。 另外,我不确定互斥锁是否可以锁定文件,尽管我仍然在.Net 4.0库中读取它。 有没有人有任何建议,如果有一个基于代码的解决方案来解决这个问题?

为什么我的图像不会移动?

我正在制作一个2D自上而下的游戏,玩家控制着一只猫。 为此,此人使用WASD键移动。 我有Form1,GameManager,Cat和Moveable类。 Form1向GameManager发送cat imagelist和e.graphics(用于图片框)。 GameManager有一个计时器,每个勾选检查猫是否已经移动。 Cat处理移动逻辑。 当我运行程序时,cat精灵显示在其初始位置,但是在按下键时不会移动。 我无法弄清楚我的问题,有人可以帮忙吗? 这是我的课程: Form1中: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace CatAndMouse { public partial class Form1 : Form { GameManager myGM = new GameManager(); public Form1() { InitializeComponent(); newGame(); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { […]