.net-2.0

How does SelectedListViewItemCollection implement IList but not have Add()?

元气小坏坏 提交于 2020-01-05 14:12:43
问题 I am trying to mimic the way a ListView and other controls handle SelectedItems collections. I have a class with a collection of items and each Item has a Selected property. I want to mimic the smart behavior where an Item can change its own Selected property and upon doing so would raise a SelectedItemsChanged event in the parent class, and the SelectedItems collection should now reflect the change. I am trying to implement a SelectedItemsCollection class which does not contain an inner list

How does SelectedListViewItemCollection implement IList but not have Add()?

戏子无情 提交于 2020-01-05 14:12:20
问题 I am trying to mimic the way a ListView and other controls handle SelectedItems collections. I have a class with a collection of items and each Item has a Selected property. I want to mimic the smart behavior where an Item can change its own Selected property and upon doing so would raise a SelectedItemsChanged event in the parent class, and the SelectedItems collection should now reflect the change. I am trying to implement a SelectedItemsCollection class which does not contain an inner list

Prevent RichTextBox from auto scrolling

♀尐吖头ヾ 提交于 2020-01-05 12:13:49
问题 I want to append text to a RichTextBox control but I don't want to interfere with the user's scroll position or text selection. The best that I've been able to do so far is to save the SelectionStart and SelectionLength properties and restore them after I append my text. This is close but the cursor ends up at the top of the control rather than wherever it was prior to the append. Is this possible? 回答1: Ok here is exactly what you need: Richtextbox :- controlling scrolling when appending text

Correct use of fields that are encapsulated in properties inside a class

孤街浪徒 提交于 2020-01-04 15:58:13
问题 Which scenario should I use for changing private fields inside class methods/properties: public class Example { private int intVar = 0; private string stringVar = string.Empty; public int IntVar { get { return this.intvar; } set { this.intvar = value; } } public string StringVar { get { return this.stringVar ; } set { this.stringVar = value; } } private void SomeMethod() { //change fields in this way: this.intVar = 50; this.stringVar = "changed"; //or that way(through properties): this.IntVar

Correct use of fields that are encapsulated in properties inside a class

爷,独闯天下 提交于 2020-01-04 15:58:08
问题 Which scenario should I use for changing private fields inside class methods/properties: public class Example { private int intVar = 0; private string stringVar = string.Empty; public int IntVar { get { return this.intvar; } set { this.intvar = value; } } public string StringVar { get { return this.stringVar ; } set { this.stringVar = value; } } private void SomeMethod() { //change fields in this way: this.intVar = 50; this.stringVar = "changed"; //or that way(through properties): this.IntVar

How does the Multiview control handle its Viewstate?

回眸只為那壹抹淺笑 提交于 2020-01-04 14:09:19
问题 Does the Multiview control contain the viewstate information for each of its views regardless of whether or not the view is currently visible? 回答1: Yes it does, all the views are still there, just the inactive ones are hidden/disabled. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.multiview_properties.aspx 回答2: I believe so, yes. It would be quite simple to confirm using a ViewState Decoder (google it, there are tools available from Fritz Onion or as FireFox plugins). 回答3:

Reverse a ResourceManager

廉价感情. 提交于 2020-01-04 03:15:15
问题 If you do ResourceManager.GetString(Key), you can get the value of an item in a resource. Is there a way to do a reverse lookup to get the key from the resource given the value (essentially de-translate)? 回答1: You should be able to get the ResourceSet and iterate over it's values and return the key if they are equal. Just remember, you need to compare values, not references. Something along these lines (Not compiled and tested, but something similar) System.Resources.ResourceManager rm = new

Maximize a window programmatically and prevent the user from changing the windows state

假装没事ソ 提交于 2020-01-03 06:48:08
问题 How do I maximize a window programmatically so that it cannot be resized once it reaches the maximized state (for example, maximize Internet Explorer and see it)? I set FormWindowState property as this.WindowState = FormWindowState.Maximized; this.MaximizedBounds = (x,y); but it doesn't work. How do I do this? The window I want to maximize is a window in my application. 回答1: When your form is maximized, set its minimum size = max size, so user cannot resize it. this.WindowState =

WinMM Library Issues

一笑奈何 提交于 2020-01-03 05:41:08
问题 I wrote a WinMM library wrapper library that exposes WaveOut and WaveIn classes for the purpose of recording and playing raw audio streams. Everything works great, but in order to follow the operating system specs on how to handle the finished buffers, I added a thread that unprepares the buffers and frees the memory. I also got all of the synchronization down, so that the classes are solid and thread-safe. However, there seems to be a rare issue where I add a buffer to the WaveOut device and

Virtual Database in Memory

烈酒焚心 提交于 2020-01-02 07:10:13
问题 Imagine the following: I have a table of 57,000 items that i regularly use in my application to figure out things like targeting groups etc. instead of querying the database 300,000 times a day, for a table that hardly ever changes it's data, is there a way to store its information in my application and poll data in memory directly? Or, do I have to create some sort of custom datatype for each row and iterate through testing each row, to check for the results i want? After some googling, the