Click here to Skip to main content
15,887,214 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Must be simple question for .NET interop gurus here... Pin
igor196011-Jun-03 6:39
igor196011-Jun-03 6:39 
GeneralRe: Must be simple question for .NET interop gurus here... Pin
Shaun Wilde11-Jun-03 8:56
Shaun Wilde11-Jun-03 8:56 
GeneralRe: Must be simple question for .NET interop gurus here... Pin
Anonymous10118-Jun-03 7:06
Anonymous10118-Jun-03 7:06 
GeneralRe: Must be simple question for .NET interop gurus here... Pin
igor196018-Jun-03 8:51
igor196018-Jun-03 8:51 
GeneralRe: Must be simple question for .NET interop gurus here... Pin
Anonymous10118-Jun-03 16:58
Anonymous10118-Jun-03 16:58 
GeneralRe: Must be simple question for .NET interop gurus here... Pin
igor196018-Jun-03 19:19
igor196018-Jun-03 19:19 
GeneralFlagsAttribute on enum Pin
Chris Richner8-Jun-03 15:26
Chris Richner8-Jun-03 15:26 
GeneralRe: FlagsAttribute on enum Pin
leppie18-Jun-03 7:12
leppie18-Jun-03 7:12 
// Stephen Toub
// stoub@microsoft.com
//
// FlaggedEnumEditor.cs
// UITypeEditor for flag enumerations
//
// July 26th, 2002
// v1.0.0
//
// To Use:
// [Editor(typeof(FlaggedEnumEditor), typeof(UITypeEditor))]
// public SomeFlaggedEnum ExampleProperty { get { return _theEnum; } set { _theEnum = value; } }

using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Design;
using System.Windows.Forms.Design;

namespace Toub.Windows.Forms.Design
{
/// <summary>Editor for flag enumerations.</summary>
public class FlaggedEnumEditor : UITypeEditor
{
#region Construction
/// <summary>Initialize the editor.</summary>
public FlaggedEnumEditor() {}
#endregion

#region Editting Values
/// <summary>Edits the specified object's value using the editor style indicated by GetEditStyle.</summary>
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
/// <param name="provider">An IServiceProvider that this editor can use to obtain services.</param>
/// <param name="value">The object to edit.</param>
/// <returns>The new value of the object.</returns>
public override object EditValue(
ITypeDescriptorContext context, IServiceProvider provider, object value)
{
// Make sure the context and the property are valid.
if (context != null && context.Instance != null &&
context.PropertyDescriptor != null &&
context.PropertyDescriptor.PropertyType.IsEnum &&
provider != null)
{
// Create the listbox for display
CheckedListBox listBox = new CheckedListBox();
listBox.CheckOnClick = true;

// Get the editor used to display the list box
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

// Get all of the names in the enum and use them to populate the listbox.
Type t = context.PropertyDescriptor.PropertyType;
foreach(string enumName in (string[])Enum.GetNames(t))
{
// We add the enum name, but only if it is selected.
bool isChecked = (((int)value) & (int)Enum.Parse(t, enumName)) != 0;
listBox.Items.Add(enumName, isChecked);
}

// Display the list box
edSvc.DropDownControl(listBox);

// Get all selected values
int enumIntValue = 0;
foreach(string str in listBox.CheckedItems) enumIntValue |= (int)Enum.Parse(t, str);

// Return the new enum
return Enum.ToObject(t, enumIntValue);
}

// Something went wrong; just return the original value
return value;
}

/// <summary>Gets the editor style used by the EditValue method.</summary>
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue.</returns>
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
// The listbox is a drop down control.
if (context != null && context.Instance != null)
{
return UITypeEditorEditStyle.DropDown;
}
return base.GetEditStyle(context);
}
#endregion
}
}

There you go Smile | :)
General.NET concept Pin
Shah Shehpori8-Jun-03 7:07
sussShah Shehpori8-Jun-03 7:07 
GeneralRe: .NET concept Pin
J. Dunlap8-Jun-03 7:46
J. Dunlap8-Jun-03 7:46 
GeneralRe: .NET concept Pin
Daniel Turini13-Jun-03 10:39
Daniel Turini13-Jun-03 10:39 
GeneralAssembly files Pin
mischextra7-Jun-03 22:33
mischextra7-Jun-03 22:33 
GeneralRe: Assembly files Pin
leppie7-Jun-03 23:06
leppie7-Jun-03 23:06 
Generala very simple question Pin
Anonymous6-Jun-03 7:31
Anonymous6-Jun-03 7:31 
GeneralRe: a very simple question Pin
leppie6-Jun-03 8:53
leppie6-Jun-03 8:53 
Generalusing System.Web.Services; Pin
Anonymous6-Jun-03 6:57
Anonymous6-Jun-03 6:57 
GeneralRe: using System.Web.Services; Pin
Anonymous6-Jun-03 7:07
Anonymous6-Jun-03 7:07 
GeneralProblem with serviced components in COM+ Pin
DeathStar5-Jun-03 23:48
DeathStar5-Jun-03 23:48 
QuestionChannel's?? Pin
Kramins5-Jun-03 10:37
Kramins5-Jun-03 10:37 
AnswerRe: Channel's?? Pin
Laimis7-Jun-03 9:52
Laimis7-Jun-03 9:52 
GeneralRe: Channel's?? Pin
Kramins13-Jun-03 2:28
Kramins13-Jun-03 2:28 
GeneralMaster-Detail datagrid Pin
Madhuri Mittal5-Jun-03 6:39
Madhuri Mittal5-Jun-03 6:39 
General.config files and Setup projects Pin
Callixte.5-Jun-03 4:09
Callixte.5-Jun-03 4:09 
GeneralRe: .config files and Setup projects Pin
James T. Johnson5-Jun-03 4:15
James T. Johnson5-Jun-03 4:15 
General.NET 1.0 and 1.1 Pin
Le centriste5-Jun-03 3:30
Le centriste5-Jun-03 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.