NumericUpDown ValueChanged事件会立即产生影响吗?(NumericUpDown ValueChanged event with immediate consequences?)

我正在用C#(.NET 4.0)编写一个小应用程序。 我想在numericUpDown中值更改时触发事件,但似乎当控件失去焦点或有多个更改时,numericUpDown ValueChanged将触发。

详细说明:我使用对象的属性绑定(OnPropertyChanged)numericUpDown,以便立即反映更改。 但我还需要使用这个新更改的numericUpDown值来计算某些内容(全局/与对象无关)。 但是如果我使用ValueChanged事件,那就太晚了。

简短的介绍:

我需要一个与OnPropertyChanged具有类似功能的事件。

我能做什么?

编辑:在ValueChanged事件处理程序中,我对对象进行了一些计算,但是已更改的值尚未提交给object属性,因此我认为ValueChanged事件滞后。

感谢您的帮助。


I'm writing a small application in C# (.NET 4.0). I want to fire an event when value changes in numericUpDown, but it seems that numericUpDown ValueChanged fires when control loses focus or when there are multiple changes.

Long description: I am binding (OnPropertyChanged) numericUpDown with a property of an object, so that the changes are reflected immediately. But I also need to calculate something (global / not related to object) using this newly changed value of numericUpDown. But if I use ValueChanged event, it fires too late.

Short description:

I need an event with similar functionality to OnPropertyChanged.

What can I do?

EDIT: In ValueChanged event handler I did some calculations on the objects, but the value that has changed wasn't yet committed to the object property, thus I thought that the ValueChanged event was lagging behind.

Thank you for your help.


原文:https://stackoverflow.com/questions/11168922
2022-10-30 16:10

满意答案

如果我正确理解你的问题,那么这样的事情可能有效:

for %%i in (
     "D:\Folder4\subfolder1\*.bat"
     "D:\Folder4\subfolder2\*.bat"
     "D:\Folder4\subfolder3\*.bat"
     "D:\Folder4\subfolder4\*.bat"
     "D:\Folder4\subfolder5\*.bat"
     "D:\Folder4\subfolder6\*.bat"
    ) do XCOPY /U /Y "C:\folder1\*.bat" "%%i"

基本上XCOPY命令有我认为你需要的选项。

编辑

我的理解在增长:P ......这可能更符合您的要求:

@echo off
for /r D:\Folder4\ %%i in (*.bat) do (
for /r C:\folder\ %%j in (*.bat) do (
if %%~ni == %%~nj XCOPY /U /Y "%%j" "%%i"
)
)
pause

If I'm understanding your question correctly, then something like this may work:

for %%i in (
     "D:\Folder4\subfolder1\*.bat"
     "D:\Folder4\subfolder2\*.bat"
     "D:\Folder4\subfolder3\*.bat"
     "D:\Folder4\subfolder4\*.bat"
     "D:\Folder4\subfolder5\*.bat"
     "D:\Folder4\subfolder6\*.bat"
    ) do XCOPY /U /Y "C:\folder1\*.bat" "%%i"

Basically the XCOPY command has the options I believe you require.

EDIT

My understanding grows :P ...this perhaps is more what you seek:

@echo off
for /r D:\Folder4\ %%i in (*.bat) do (
for /r C:\folder\ %%j in (*.bat) do (
if %%~ni == %%~nj XCOPY /U /Y "%%j" "%%i"
)
)
pause

相关问答

更多

用于查找和替换多个子文件夹中的文件的Bat脚本 - 将.java文件替换为特定文件夹中的.class文件(Bat script to find and replace files in multiple subfolders - replace .java files with .class files from specific folder)

for /f "delims=" %%a in ('dir /b /a-d "c:\workspace\changeset\com\folder\*.java"') do ( if exist "c:\workspace\target\class\com\folder\%%~na.class" ( echo copy "c:\workspace\target\class\com\folder\%%~na.class" "c:\workspace\changeset\com\folder\%%...

如何重命名多个子文件夹中多个文件的扩展名(.jpg)?(How to rename the extension (.jpg) of multiple files in multiple subfolders?)

正如@bgalea指出的那样,代码的问题是批处理使用%%a而不是%a 。 但是,虽然这会修复代码的语法,但仍然存在错误。 将文件重命名为其他扩展名实际上并不会转换文件,例如,您无法将.txt文件重命名为.mp4并期望它播放视频。 不幸的是,Windows没有本地方式来转换图像。 这意味着您需要第三方工具,例如ImageMagick (免费)。 如果安装了ImageMagick,则可以使用convert命令,如下所示: @ECHO OFF FOR /f "delims=*" %%a IN ('d...

如何将特定文件从多个子文件夹移动到各自的父文件夹?(How can I move specific files from multiple subfolders to their respective parent folder? (Windows batch))

这是一个可能的解决方案,因为路径示例中只有XXX部分是可变的: rem // Enumerate `FolderName*` directories: for /D %%R in ("Carabidae\Pterostichinae\FolderName*") do ( rem // Enumerate `Stack*` sub-directories within `dor` sub-directories: for /F "delims= eol=|" %%D in ('dir...

Bash:将多个文件移动到子文件夹中(Bash: Moving multiple files into subfolders)

for i in {1..39} do mkdir -p r${i}/ mv *run${i}_* r${i}/ done for i in {1..39} do mkdir -p r${i}/ mv *run${i}_* r${i}/ done

批量替换多个子文件夹中的多个文件(Batch replace multiple files in multiple subfolders)

如果我正确理解你的问题,那么这样的事情可能有效: for %%i in ( "D:\Folder4\subfolder1\*.bat" "D:\Folder4\subfolder2\*.bat" "D:\Folder4\subfolder3\*.bat" "D:\Folder4\subfolder4\*.bat" "D:\Folder4\subfolder5\*.bat" "D:\Folder4\subfolder6\*.bat" ...

使用循环来rar主文件夹中的多个子文件夹(Using a loop to rar multiple subfolders in a main folder)

打开命令提示符窗口,键入并执行for /? 并读取此命令的帮助输出。 选项/D已在第一个帮助页面上解释,该页面用于在目录的每个子目录上执行命令。 下面的批处理文件使用控制台版本的WinRAR使用命令m (move = archive和delete on success)而不是使用switch -df命令a来存档C:\Users\Admin\Folder每个子文件夹。 @echo off for /D %%F in ("C:\Users\Admin\Folder\*") do ( "%Pro...

如何在整个master文件夹中扫描多个子文件夹?(How do i scan multiple subfolders within an overall masterfolder? [duplicate])

幸运的是,我有一些业余时间在工作:) 您需要递归以满足您的需求。 粗略的伪代码解释: processFiles(folder) for each subfolder in folder for each file in subfolder Do modifications next call processFiles(subFolder) next end 在VBA中,它看起来像这样: Sub openAll...

使用Windows批处理脚本在文件夹中的多个文件中查找和替换字符串(Find and replace string in multiple files within a folder using windows Batch script)

@ECHO OFF SETLOCAL :: no idea what this is aimed at doing...?? for %%* in (.) do set new=%%~n* SET new=newstring SET old=XXXX for %%f in (*.fmw) do ( echo Processing %%f... ( FOR /F "delims=" %%l IN (%%f) DO ( SET "line=%%l" ...

重命名多个子文件夹中的项目(Rename-item in multiple subfolders)

Get-ChildItem *将获取您当前的路径,因此我们使用定义您想要的路径Get-ChildItem -Path "J:\Logs"并添加recurse因为我们想要所有子文件夹中的文件。 然后让我们添加使用Get-ChildItem的include和file参数而不是Where-Object 然后,如果我们将它传递给ForEach ,我们可以在每个对象上使用Rename-Item,其中要重命名的对象是$_ , NewName将是report.txt 。 Get-ChildItem -Path ...

SSIS从多个子文件夹中获取文件(SSIS Get files from multiple subfolders)

您可以查找的其中一个选项是使用脚本任务来执行此操作。 脚本任务是嵌入在SSIS中的那些巧妙的东西之一,可以通过充分利用.Net库来做任何开箱即用的组件无法提供的东西。 这是一个链接,解释了如何做到这一点 - http://microsoft-ssis.blogspot.com.au/2011/08/foreach-ftp-file-enumerator.html One of the options you can look for is using Script Task to perform ...

相关文章

更多

storm事件管理器EventManager源码分析-event.clj

storm事件管理器定义在event.clj中,主要功能就是通过独立线程执行"事件处理函数& ...

Solr参数(DisMax Event Facet)

一.DisMax 1.tie:query and init param for tiebreaker ...

JavaScript 事件

作者:李丽媛 联系方式:lly219#gmail.com 日 期:2010-2-26 前言 ...

JavaScript 事件

作者:李丽媛 联系方式:lly219#gmail.com 日 期:2010-2-26 前言 ...

解析JavaScript的事件机制

JavaScript 的事件是以一种流的形式存在的,一个事件会有多个元素同时响应。有时候这不是我们想要 ...

HTML5服务器事件发送(Server-Sent Events)【HTML5教程 - 第十三篇】

erver-Sent Events - 单向的信息处理.一个SSE(server send event ...

触摸事件和微信实现原理

触摸事件练习 1.如果想让一个空间随你的手指的移动而移动,那么就再touchmove的方法中。 UIT ...

页面事件问题

请问各位大虾,在按F5刷新页面的时候有没有触发什么事件 问题补充: 梦中有你 写道 ...

基于YMP-WeChat模块接收并处理微信事件及消息的代码

public class MessageHandler implements IMessageHand ...

java 监听redis过期key事件实现延迟队列功能

java 监听redis过期key事件,可以实现简单的延迟队列功能。实现起来也特别简单,方法如下:一、 ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本