winforms

how to go from TreeNode.FullPath data and get the actual treenode?

余生颓废 提交于 2021-02-07 19:36:38
问题 I would like to store some data from TreeNode.FullPath and then later i would like to re-expand everything up to that point. Is there a simple way of doing it? Thanks a lot! 回答1: I had a similar problem (but I just wanted to find the treenode again) and found this: http://c-sharpe.blogspot.com/2010/01/get-treenode-from-full-path.html i know it only answers part of your problem, but better than no replies at all ;) 回答2: You can write it as an extension method to the TreeNodeCollection : using

Why does BindingSource not tell me which property has changed?

别等时光非礼了梦想. 提交于 2021-02-07 19:30:07
问题 I'm looking at using databinding - and the simplest thing to do seems to be to use a BindingSource to wrap my data objects. However - while the CurrentItemChanged event tells me when a property has changed, it doesn't tell me which one - and that's a vital part of what I need. Is there any way to find out which property is changing? 回答1: Your data objects need to implement the INotifyPropertyChanged interface: public class MyObject : INotifyPropertyChanged { public event

Why does BindingSource not tell me which property has changed?

£可爱£侵袭症+ 提交于 2021-02-07 19:29:20
问题 I'm looking at using databinding - and the simplest thing to do seems to be to use a BindingSource to wrap my data objects. However - while the CurrentItemChanged event tells me when a property has changed, it doesn't tell me which one - and that's a vital part of what I need. Is there any way to find out which property is changing? 回答1: Your data objects need to implement the INotifyPropertyChanged interface: public class MyObject : INotifyPropertyChanged { public event

How to change font size without creating a new font

ⅰ亾dé卋堺 提交于 2021-02-07 18:47:02
问题 Is it possible to change the size of a font in .net winforms without having to create a new Font with the new size? 回答1: No. Font size is readonly for existing "Font" objects. 回答2: You could do something like this with an Extension method. Imports System.Runtime.CompilerServices Module FontExtensions <Extension()> Public Function ToSize(ByVal OriginalFont As Font, ByVal NewSize As Single) As Font Dim NewFont As Font NewFont = New Font(OriginalFont.FontFamily, NewSize, OriginalFont.Style)

How to change font size without creating a new font

帅比萌擦擦* 提交于 2021-02-07 18:46:28
问题 Is it possible to change the size of a font in .net winforms without having to create a new Font with the new size? 回答1: No. Font size is readonly for existing "Font" objects. 回答2: You could do something like this with an Extension method. Imports System.Runtime.CompilerServices Module FontExtensions <Extension()> Public Function ToSize(ByVal OriginalFont As Font, ByVal NewSize As Single) As Font Dim NewFont As Font NewFont = New Font(OriginalFont.FontFamily, NewSize, OriginalFont.Style)

Winform won't resize when setting Size property

拥有回忆 提交于 2021-02-07 18:11:08
问题 I have a WinForm that is used to host a WebBrowser control. I want to dynamically resize the form based on the document size that the browser loads. I can successfully read the document size from within the WebBrowser control and I set the form size based on that, but the form simply will not resize. The resize is within the WebBrowsers DocumentCompleted event: private void ViewWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { ViewWebBrowser.Height =

What files are mandatory in release windows form?

一世执手 提交于 2021-02-07 14:55:24
问题 I have files in ...bin/release where is my windows form application, I have used EEPlus library as well. What the files do I need to send to client to have application work correctly? My files: name.exe name.exe.config name.pdb name.vshost.exe name.vshost.exe.config name.vshost.exe.manifest EEPlus.dll EEPlus.xml I know that first two are mandatory, but what about all rest? thanks in advance 回答1: name.exe //necessary, it is your main executable name.exe.config //necessary, it is your

ListBox SelectedValueChanged/SelectedIndexChanged not firing when data source changes

微笑、不失礼 提交于 2021-02-07 14:28:29
问题 I need to keep track of the selected item on a ListBox to update/disable other controls according to the currently selected value. This is the code to reproduce the issue: public partial class Form1 : Form { private readonly BindingList<string> List = new BindingList<string>(); public Form1() { InitializeComponent(); listBox1.DataSource = List; listBox1.SelectedValueChanged += (s, e) => System.Diagnostics.Debug.WriteLine("VALUE"); listBox1.SelectedIndexChanged += (s, e) => System.Diagnostics

Why doesn't AutoSize property in Windows Form TextBox appear in IntelliSense

孤街浪徒 提交于 2021-02-07 13:42:59
问题 According into the specs (http://msdn.microsoft.com/en-us/library/k63c05yf.aspx) Textboxes in Windows Forms should have an autosize property. And it actually doesn't break when you type in TextBox1.AutoSize = true . However, it doesn't seem to appear in the list of IntelliSense properties. Why is this? I have tried recompiling and it all compiles, but the textbox.autosize property never appears. 回答1: The AutoSize property for TextBox is always true, forced by the constructor. The property is

Why doesn't AutoSize property in Windows Form TextBox appear in IntelliSense

淺唱寂寞╮ 提交于 2021-02-07 13:42:12
问题 According into the specs (http://msdn.microsoft.com/en-us/library/k63c05yf.aspx) Textboxes in Windows Forms should have an autosize property. And it actually doesn't break when you type in TextBox1.AutoSize = true . However, it doesn't seem to appear in the list of IntelliSense properties. Why is this? I have tried recompiling and it all compiles, but the textbox.autosize property never appears. 回答1: The AutoSize property for TextBox is always true, forced by the constructor. The property is