WinForms如何调用按钮上的双击事件?(WinForms how to call a Double-Click Event on a Button?)
当点击一次按钮时,我不希望事件发生,而只是在双击按钮时才会发生事件。 令人遗憾的是,双击事件并未出现在IDE中的事件列表中。
任何人都知道这个问题很好的解决方案? 谢谢!
Rather than making an event occur when a button is clicked once, I would like the event to occur only when the button is double-clicked. Sadly the double-click event doesn't appear in the list of Events in the IDE.
Anyone know a good solution to this problem? Thank you!
原文:https://stackoverflow.com/questions/13486245
最满意答案
它没有用,因为你手动改变
props
数组--React不知道它已经改变了。 一般来说,你根本不应该改变道具。如果您真的想这样做,可以在componentDidMount中使用setState,然后通过以下方式呈现您的子组件:
class Parent extends React.Component { constructor(props) { super(props); this.state = { childComponent: null } } componentDidMount() { this.setState({ childComponent: <div>Hello</div> }); } render() { return ( <div> {this.state.childComponent} </div> ) } }
但是,无论你想做什么,都可能有更好的解决方案。 我无法想象很多情况下你只想在父装载后才能渲染东西。
It's not working because you are mutating the
props
array manually - React has no idea that it has changed. In general, you should never change props at all.If you really want to do this, you can use setState within componentDidMount, and then render your child component through that:
class Parent extends React.Component { constructor(props) { super(props); this.state = { childComponent: null } } componentDidMount() { this.setState({ childComponent: <div>Hello</div> }); } render() { return ( <div> {this.state.childComponent} </div> ) } }
However, there might be a better solution to whatever you're trying to do. I can't imagine many situations in which you'd want to render stuff only after the parent has mounted.
相关问答
更多-
你需要像孩子一样传递组件,像这样... var App = require('./App.js'); var SampleComponent = require('./SampleComponent.js'); ReactDOM.render(
, document.body ); ...然后将它们追加到组件主体中: var App = React.createClass ... -
你应该让React根据你提供的道具来处理component1和2。 例如,使用ES6和React 0.14纯组件: const App = ({has2}) =>
{has2 && } -
React:新安装的子组件无法访问父组件引用?(React: Parent component refs not accessible to newly mounted child component?)[2024-01-29]
父组件在“挂载”所有子组件之后才会“挂载”。 因此,当您的Message componentDidMount正在执行时,您的ScrollArea仍处于“挂载”过程中。 您的问题是您对交互建模的方式的结果:您有一个“子”组件来指示某些父组件的行为。 如果你让你的父组件负责这个滚动行为,那么一切都会起作用。 具体来说,将一个componentDidMount方法添加到MessageSection组件并将逻辑放在那里: componentDidMount: function() { // Assume y ... -
我会改为使用state,因为不建议使用forceUpdate() 来自React docs: 调用forceUpdate()将导致在组件上调用render(),跳过shouldComponentUpdate()。 这将触发子组件的正常生命周期方法,包括每个子组件的shouldComponentUpdate()方法。 如果标记发生变化,React仍然只会更新DOM。 通常你应该尽量避免使用forceUpdate(),只能在render()中读取this.props和this.state。 这使您的组件“纯粹” ...
-
它没有用,因为你手动改变props数组--React不知道它已经改变了。 一般来说,你根本不应该改变道具。 如果您真的想这样做,可以在componentDidMount中使用setState,然后通过以下方式呈现您的子组件: class Parent extends React.Component { constructor(props) { super(props); this.state = { childComponent: null } } com ...
-
React:将子插入的子元素返回父级以更新状态(React: Give back the child new inserted element to parent for update the state)[2021-10-18]
让父( TodosPage )将函数作为其ListForm ( TodosPage )传递给它。 然后onSubmit ,让ListForm调用该函数。 class TodosPage extends React.Component { handleListFormSubmit = (goodId) => { // do something with goodId } render() { returnReact - 带有子的父组件在不同的dom容器中(React - parent component with child in separate dom containers)[2022-03-08]
您可以使用componentDidMount和componentDidUpdate挂钩来实现此目的,以便在父组件更新时手动呈现子组件: class Child1 extends React.Component { render() { const {count, onClick} = this.props; return (Child 1 {count}); } } class Ch ...Angular2 - 尝试将父组件添加到子组件中(Angular2 - Trying to add a component into a child component from parent)[2022-07-10]
不确定我是否完全理解你的问题,但我认为这就是你想要的 ngAfterViewInit(){ this._loader.loadIntoLocation(ChildComponent,this._elementRef,'element') .then(childComponent => childComponent.instance.addElement()); } this._loader.loadIntoLocation(...)返回一个Promise ,它通过对添加元素的引用完成。 N ...React Native:在关闭子组件上的模式后显示父组件(React Native : Show parent component after closing a modal on child component)[2022-05-12]
简单的deleteSelectedRecord函数调用setModalVisible(false) -Simple in deleteSelectedRecord function call setModalVisible(false)您可以在子组件中使用rest destructuring pattern。 根据documentation Rest属性收集剩余的自身可枚举属性键,这些键尚未被destructuring模式拾取。 当你直接将道具分配给DOM元素时,你应该仔细使用rest destruct,因为从v16 onwards没有对属性进行检查,所有属性都允许在DOM元素上传递,所以即使它不相关,属性将传递给您可能不想要的DOM元素 PS确保您不想传递给DOM的所有属性都单独进行解构。 示例代码段 export default cl ...相关文章
更多- Becoming a data scientist
- A Great List of Windows Tools
- How to Start a Business in 10 Days
- 按钮样式
- [转]So You Want To Be A Producer
- Become a Master Designer: Rule Three: Contrast, Contrast, Contrast
- storm事件管理器EventManager源码分析-event.clj
- Solr: a custom Search RequestHandler
- Spring Data: a new perspective of data operations
- Create a Bootable MicroSD Card
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。