表单不更新用户控件
从帖子“增加用户控制而不更新”...... 在Windows环境下使用C#、.Net 2.0。
UserControl1 - 根据 NumberOfCells 属性将单元格绘制到位图缓冲区 UserControl2 - 面板包含 UserControl1,必要时显示垂直滚动;还包含 NumberOfCells,它设置 UserControl1 的 NumberOfCells。 Formf1 - 包含更新 UserControl2 的 NumericUpDown 控件(仅增量) - 假设如此!
当我将表单上的控件增加 20 时,UserControl1 添加必要的单元格,UserControl2 相应地显示垂直滚动条,但表单不会“重绘”到更新/正确的图像!意思是,在我增加 20 后,会添加单元格、添加垂直滚动条……但显示的图像只是其他所有内容都在扩展。
我将控件重置为滚动到最顶部并且滚动有效,但图像仍然是静态的...直到我调整表单大小,更具体地说,当我将其从最大化更改为窗口时,反之亦然!
我该怎么做才能“重置/重绘”正确的图像???先感谢您。
- 劳伦斯
From the post "Growing user control not updating"...
Using C#, .Net 2.0 in a Windows environment.
UserControl1 - draws cells to a bitmap buffer dependent upon NumberOfCells property
UserControl2 - panel contains UserControl1 which displays vertical scroll when necessary; also contains NumberOfCells which sets UserControl1's NumberOfCells.
Formf1 - contains NumericUpDown controls (just increments) which updates the UserControl2 - suppose to!
When I increment the control on the form by say 20, UserControl1 adds the necessary cells, UserControl2 displays the vertical scroll bar accordingly, BUT the form does not 'redraw' to the updated/correct image!! Meaning, after I increment by 20, cells are added, vertical scrool bar added... but the image shown is just everything else expanding.
I reset the control to scoll to the very TOP and the scrolling works, but the image is still staic... UNTIL I resize my form, more specifically, when I change it from maximize to window or vice versa!!!
What can I do to 'reset/redraw' the correct image???? Thank you in advance.
- Lawrence
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这是 C# 和 Windows 窗体,我会尝试在控件上调用 Update() 或 Refresh() 以使其自行重绘。
If this is C# and Windows Forms I would try calling Update() or Refresh() on the control to make it redraw itself.
尝试在 Scroll 事件和 NumberOfCells 属性中调用 Refresh。
Try calling Refresh in the Scroll events and the NumberOfCells Property.