|
|
Hi,
how to enable editing in propertygrid? A normal enum can be edited via Properties (F4). But how to design a enum with FlagsAttribute? Is there a UITypeEditor which provides a checkedlistbox?
.:[Greets from Jerry Maguire]:.
|
|
|
|
|
// 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
|
|
|
|
|
I've not yet started working on .NET so just want to clarify a primary concept about .NET by asking question here.
Friends, in programming with Visual C++ 6, we deal directly Windows Operating systems API. For example consider Winsock API available with operating system. Whenever there is a need to write an application that connects to other systems on a network, we use Winsock API functions to do so. Microsoft made our life easy by encapsulating various Winsock API calls in MFC classes. These MFC socket classes do nothing more than making our life easy. These classes are just the wrapper around same Winsock API functions that we were using before.
I like to ask you the role of .NET in this case. In .NET there are also Socket classes which according to many people are much better than MFC socket classes. Now what is the role of .NET in this case. Here is my question:
Is the role of .NET socket classes same as that of MFC. I mean are .NET classes internally calling the same native Operating system APIs just like MFC ??
|
|
|
|
|
Most likely yes. In most cases, the .NET Base Class Library uses the same API's that you would use in C++.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Shah Shehpori wrote:
Is the role of .NET socket classes same as that of MFC. I mean are .NET classes internally calling the same native Operating system APIs just like MFC ??
Yes, but they have a much more modern design, and are much easier to write. The design goal seemed to be "the user of these classes should only need to get into detail if he needs to get into detail".
ORACLE One Real A$#h%le Called Lary Ellison
|
|
|
|
|
Hi!
i think i have a problem with .net framework. There is a resourceviewer called reflector. whenn i start it i get an errormassage:
the following assembly name can't be resolved automatically:
System.Windows.Forms.resources, Version=1.0.5000.0, Culture=de-DE, PublicKeyToken=b77a5c561934e089
please select the assembly file manually.
i reinstalled the framework sdk and the framework redist (both v 1.1). but the error is still comming.
what's wrong? please help.
misch
|
|
|
|
|
mischextra wrote:
System.Windows.Forms.resources, Version=1.0.5000.0, Culture=de-DE, PublicKeyToken=b77a5c561934e089
please select the assembly file manually.
It appears to a cultural problem. You dont specify if this a Reflector problem or a problem related to a assembly loaded in Reflector, which pretty much can throw the same message. Try setting your regional settings to neutral (US?).
<a TITLE="See my user info" href=http:
|
|
|
|
|
I'm new to CSharp, this question may seem stupid to you guys, really appreciate your answer.
I created 2 files in one projcet: a.cs, b.cs,
now a.cs will reference some class defined in b.cs, I don't see in C# you can do something like "include b.cs", nevertheless both build ok. How does a.cs know to get definition from b.cs?
|
|
|
|
|
The C# compiler will automaticalliy resolve all types in the input files. Thus you can have a.cs with C : B and A and b.cs with B : A, and it will still resolve without issues. If the source is already an assembly you just need to reference that assembly and all its types will be resolved to.
<a TITLE="See my user info" href=http:
|
|
|
|
|
when i tried to include "using System.Web.Services;" in a C# file,
got the following error:
"The type or namespace name 'Services' does not exist in the class or namespace 'System.Web' (are you missing an assembly reference?)"
why is that?
Thanks!
|
|
|
|
|
just saw a message downstairs, i added reference it's ok now
|
|
|
|
|
Following is a description of the problem I am having with W2K3, COM+ and Serviced component:
MSDN says: Article Tile: Serviced Component Overview
On Windows 2000 platforms, COM+ always loads the most recent version of the common language runtime for the component you're creating. This means that on a computer with both .NET Framework version 1.0 and .NET Framework version 1.1 installed, .NET Framework version 1.1 is always loaded. As a workaround, you can create a COM+ dllhost.exe.configuration file that enables you to "lock" all applications to a specific version of .NET Framework. On Windows XP and Windows Server 2003 platforms, the Application Root Directory setting can be used to point COM+ to an appropriate directory for its configuration file.
The bit I am interested in is the Application Root Directory setting, I have tried to set this in an application but the properties which give me information from this file still look for the dllhost.exe.config in the System32 directory. I want to confirm that this feature is not working or that there is something else I need to do, to allow the above to be exposed/pulled through to my COM+ objects.
Anton Schoeman
|
|
|
|
|
I don't get Channel's (TCPChannel, HTTPChannel), is it just a new way of doing Client Server Applications????
Could some one shead some light on this for me... thanks
|
|
|
|
|
TcpChannel and HttpChannel are used for .NET framework's Remoting part. Remoting can be said to be one way of building client server apps, yes. Basically it's a mechanism for client and server to communicate. And they communicate through the channels (tcp or http) with messages passing through various sinks that can be used to encrypt/decrypt or processed in some other way.
|
|
|
|
|
|
I have Master-Detail datagrid. The detail datagrid is embedded in the Master datagrid. In the detail datagrid I want to implement paging ,sorting etc. I have addes the event handlers delegates manually. For some reason the pageindexchanged or sort events for the detail datagrid. Does anyone know of this behaviour? I saw a lot Master-Details datagrids on the internet, nobody seems to have implemented paging-sorting for details grid embedded within a datagrid. thanks
Madhuri Mittal
|
|
|
|
|
Hello everybody,
Perhaps someone has experienced the same problem as I had:
I have developped an application and this application is a bit complexe to configure: several DBs, some parameters that depends on the system (such as log files path) and so on. These configuration item are stored in the .config file.
Now, I want to distribute my application. So I built a setup project for it. My problem is that the msi file contains my .config parameters which will not work on an other system. The simple solution is to edit manually the config file after install, which is not very convenient.
I was wondering if there is a way to automaticaly add screens in the setup wizard to configure the application and write the config file while installing.
tahnks in advance.
|
|
|
|
|
I don't think the setup stuff that comes with VS.NET can do this directly. You would have to create some custom actions which would then do the work of editing the .config file.
Some time last year I tried to create a custom action, but eventually gave up on it. I can't remember what I was trying to do though.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
I have .NET 1.0 (v1.0.3705) and .NET 1.1 (v1.1.4322), but my programs use .NET 1.0. I noticed the presence of the FrameworkVersion=v1.0.3705 environment variable on VS.NET command prompt, which I don't know how to change.
How do you make your programs use the .NET 1.1 version?
|
|
|
|
|
Your programs should automatically use the 1.1 version when it is available (unless you specify otherwise in a .config file). But you probably want to compile with 1.1 so you can use the new features as well
When you installed the SDK, a batch file was installed that sets up the environment variables. On my computer this is at: C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\sdkvars.bat. If you point a shortcut to: %comspec% /k C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\sdkvars.bat then when you open that shortcut you can compile with .NET 1.1.
VS.NET 2002 cannot target 1.1, it was hard coded to target 1.0; so unless someone "patches" it you are stuck with 1.0 for builds through it.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
How do you know your apps are using .NET Framework v1.0 and not v1.1?
There is one test I know for sure; With ADO.NET try to use the RowCount</count> property of a <code>SqlDataReader If that works then you are using 1.1 because it is not available in 1.0.
Also that VS.NET cmd prmpt env var: Do you have VS.NET 2003 installed? If not then you have 2002 installed and it will be setup with v1.0.3705 . Once you install 2003 then normally the cmd prmpt in the 2003 folder will be v1.1.
Paul Watson Bluegrass Cape Town, South Africa
Chris Losinger wrote:
i hate needles so much i can't even imagine allowing one near The Little Programmer
|
|
|
|
|
Paul Watson wrote:
try to use the RowCount property of a SqlDataReader
Have you tested this out at all yet performance wise? Just curious because I have not installed 1.1 yet. I wonder who much this effects the performance of the datareader.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
I'm currently working on a Softwareproject where it must be possible that two applications could talk togeter (with RPC's and only local). My Project bases on the .NET Framework and I'm new to it (without the .NET Framework i would it implement with COM).
I read on a few Articles that Remoting is the "COM" in the .NET Framework. But theres one thing that bothers me: When I'd like to use Remoting only local, why must I allways declare a port?
Can I use Remoting without a port or is there any other possibility for implementing RPC's?
Thanks for any help in advance!
And sorry for my bad english...
Regards Stefan
|
|
|
|
|
I downloaded and installed the .NET Framework 1.1. I then downloaded the .NET Framework SDK 1.1 and installed. I then downloaded the SharpDevelop IDE and proceeded to use that.
I tried to create a C# Service. When I tried to compile the template C# Service it creates it informed me that the namespace "Installer" could not be found. I looked this up in the SDK documentation and it said that it was part of System.Configuration.Installer
Everything I read says this is where it is. I can't find this anywhere on my system. It wasn't installed. Does it get installed with something else other than the .NET Framework SDK?
Help please.
--
"The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed."
-- Abraham Lincoln
|
|
|
|