system.componentmodel

Click event delayed in ContextMenu attached to NotifyIcon

你离开我真会死。 提交于 2019-12-12 02:27:27
问题 I am working on a plugin (using System.ComponentModel.Composition ) for an application to place an icon in the notification area of the Windows UI. trayMenu.MenuItems.Clear(); // Create context menu items foreach( IJob job in jobs ) { MenuItem menuItem = new MenuItem( job.Name ) {Tag = job}; menuItem.Click += MenuItemClick; trayMenu.MenuItems.Add( menuItem ); } private void MenuItemClick( object sender, EventArgs e ) { // ... } Now when I click on an item in the context menu of that icon, the

How to use a static utility method for property setters in a utility class

本秂侑毒 提交于 2019-12-11 07:49:02
问题 I'm trying to achieve two-way binding between a DataGridView and a BindingList that provides data for the DGV. Some columns do not yet reflect changes in the underlying list and I think it's because I have not provided property setter(s) to notify of property changes. Rather than code the setter for the Rows property the same way I did for the Process property, I'm trying to get more "elegant" and I realize I am stuck.... I stumbled upon a very interesting writeup for a more elegant approach

Get Component's Parent Container in Compact Framework

岁酱吖の 提交于 2019-12-11 04:48:38
问题 I basically need to do the same thing as in: Get Component's Parent Form however in compact framework there is no definition of IDesignerHost Any idea how to do this? EDIT: It is System.ComponentModel.Component derived component that I want to drop on some System.Windows.Forms.Container control. The reason I need to reference to this is that I don't want to manually set Parent Container for my component in each form I will drop component to. 回答1: In the Compact Framework a Form's components

Get Description Attributes From a Flagged Enum

限于喜欢 提交于 2019-12-05 12:37:09
I am trying to create an extension method that will return a List<string> containing all the Description attributes for only the set values of a given [Flags] Enum . For example, suppose I have the following enum declared in my C# code: [Flags] public enum Result { [Description("Value 1 with spaces")] Value1 = 1, [Description("Value 2 with spaces")] Value2 = 2, [Description("Value 3 with spaces")] Value3 = 4, [Description("Value 4 with spaces")] Value4 = 8 } And then have a variable set as: Result y = Result.Value1 | Result.Value2 | Result.Value4; So, the call I want to create would be: List

When and why we should to use class System.ComponentModel.Container?

会有一股神秘感。 提交于 2019-12-03 11:52:28
Is anybody could explain when and why we should use System.ComponentModel.Container , please? Recently I have met using of this class here , but really cannot understand what a benefit can get us this class there. In general, System.ComponentModel namespace exists for supporting component development - components can be visual (controls) and non-visuals. IMO, one should develop Components (in this context IComponent implementations) when design time support is needed. For example, you can drag Components on to the design surface in Visual Studio and access their properties. In this context,

.NET: How do I invoke a delegate on a specific thread? (ISynchronizeInvoke, Dispatcher, AsyncOperation, SynchronizationContext, etc.)

試著忘記壹切 提交于 2019-12-02 20:49:32
Note first of all that this question is not tagged winforms or wpf or anything else GUI-specific. This is intentional, as you will see shortly. Second, sorry if this question is somewhat long. I try to pull together various bits of information floating around here and there so as to also provide valuable information. My question, however, is right under "What I would like to know". I'm on a mission to finally understand the various ways offered by .NET to invoke a delegate on a specific thread. What I would like to know: I am looking for the most general way possible (that is not Winforms or

What is the difference between IEditableObject and IRevertibleChangeTracking?

我的未来我决定 提交于 2019-11-30 11:55:39
问题 What is the difference between IEditableObject and IRevertibleChangeTracking (both from the System.ComponentModel namespace)? It looks as if the first supports explicit transaction whilst the second is more implicit - but the net result is the same. How should I go about implementing this in code? At the moment I do nothing in BeginEdit and call RejectChanges and AcceptChanges in EndEdit and CancelEdit respectively. My problem is that this will also accept the changes made prior to the

What is the difference between IEditableObject and IRevertibleChangeTracking?

前提是你 提交于 2019-11-30 02:03:20
What is the difference between IEditableObject and IRevertibleChangeTracking (both from the System.ComponentModel namespace)? It looks as if the first supports explicit transaction whilst the second is more implicit - but the net result is the same. How should I go about implementing this in code? At the moment I do nothing in BeginEdit and call RejectChanges and AcceptChanges in EndEdit and CancelEdit respectively. My problem is that this will also accept the changes made prior to the BeginEdit. Is that really what Microsoft wanted or am I trying to implement two mutually exclusive interfaces

Data Binding POCO Properties

主宰稳场 提交于 2019-11-28 17:45:38
问题 Are there any data binding frameworks (BCL or otherwise) that allow binding between any two CLR properties that implement INotifyPropertyChanged and INotifyCollectionChanged ? It seems to be it should be possible to do something like this: var binding = new Binding(); binding.Source = someSourceObject; binding.SourcePath = "Customer.Name"; binding.Target = someTargetObject; binding.TargetPath = "Client.Name"; BindingManager.Bind(binding); Where someSourceObject and someTargetObject are just

Linq expressions and extension methods to get property name

妖精的绣舞 提交于 2019-11-28 10:27:29
I was looking at this post that describes a simple way to do databinding between POCO properties: Data Binding POCO Properties One of the comments by Bevan included a simple Binder class that can be used to accomplish such data binding. It works great for what I need but I would like to implement some of the suggestions that Bevan made to improve the class, namely: Checking that source and target are assigned Checking that the properties identified by sourcePropertyName and targetPropertyName exist Checking for type compatibility between the two properties Also, given that specifying