Hi,
I want to create a method that takes in the type of a Enumeration,
passes in the Enumeration as an object, and then outputs the values
with checkboxes, and pre-checks the checkbox if that value is set in a
mask.
This is what I have so far that outputs the values as a checkbox, but
I need to pass in *any* mask so it can check if that value is set in
the mask, if yes, check the checkbox.
public static string EnumToCheckboxe s(Type enumType, string
namePrefix)
{
StringBuilder sb = new StringBuilder() ;
foreach (string item in Enum.GetNames(e numType))
{
string name = String.Format(" {0}-{1}", namePrefix,
item);
sb.Append(@"<li ><input type=""checkbox ""
name=""").Appen d(name).Append( @"""").Append(@ "
id=""").Append( name).Append(@" ""></li>");
sb.Append(item) ;
}
return sb.ToString();
}
What i'm thinking to do is:
public static string EnumToCheckboxe s(Type enumType, string
namePrefix, object mask)
{
StringBuilder sb = new StringBuilder() ;
(enumType)mask // ??????????????? ?
foreach (string item in Enum.GetNames(e numType))
{
string name = String.Format(" {0}-{1}", namePrefix,
item);
sb.Append(@"<li ><input type=""checkbox ""
name=""").Appen d(name).Append( @"""").Append(@ "
id=""").Append( name).Append(@" ""></li>");
sb.Append(item) ;
}
return sb.ToString();
} 3 1378
On 13 maio, 13:19, DotNetNewbie <snowman908...@ yahoo.comwrote:
Hi,
I want to create a method that takes in the type of a Enumeration,
passes in the Enumeration as an object, and then outputs the values
with checkboxes, and pre-checks the checkbox if that value is set in a
mask.
This is what I have so far that outputs the values as a checkbox, but
I need to pass in *any* mask so it can check if that value is set in
the mask, if yes, check the checkbox.
public static string EnumToCheckboxe s(Type enumType, string
namePrefix)
* * * * {
* * * * * * StringBuilder sb = new StringBuilder() ;
* * * * * * foreach (string item in Enum.GetNames(e numType))
* * * * * * {
* * * * * * * * string name = String.Format(" {0}-{1}", namePrefix,
item);
* * * * * * * * sb.Append(@"<li ><input type=""checkbox ""
name=""").Appen d(name).Append( @"""").Append(@ "
id=""").Append( name).Append(@" ""></li>");
* * * * * * * * sb.Append(item) ;
* * * * * * }
* * * * * * return sb.ToString();
* * * * }
What i'm thinking to do is:
public static string EnumToCheckboxe s(Type enumType, string
namePrefix, object mask)
* * * * {
* * * * * * StringBuilder sb = new StringBuilder() ;
* * * * * * (enumType)mask // ??????????????? ?
* * * * * * foreach (string item in Enum.GetNames(e numType))
* * * * * * {
* * * * * * * * string name = String.Format(" {0}-{1}", namePrefix,
item);
* * * * * * * * sb.Append(@"<li ><input type=""checkbox ""
name=""").Appen d(name).Append( @"""").Append(@ "
id=""").Append( name).Append(@" ""></li>");
* * * * * * * * sb.Append(item) ;
* * * * * * }
* * * * * * return sb.ToString();
* * * * }
Well, you´ve to learn a few thing about reflection.
Try it, it will probably help you.
Best Regards,
Breno.
On Tue, 13 May 2008 09:19:57 -0700, DotNetNewbie <sn***********@ yahoo.com>
wrote:
Hi,
I want to create a method that takes in the type of a Enumeration,
passes in the Enumeration as an object, and then outputs the values
with checkboxes, and pre-checks the checkbox if that value is set in a
mask.
This is what I have so far that outputs the values as a checkbox, but
I need to pass in *any* mask so it can check if that value is set in
the mask, if yes, check the checkbox.
What I would do is enumerate the Enum.GetValues( ) array instead of the
GetNames() array. Cast your mask and current value to int, and set the
checkbox based on that result.
You could of course parse the enumeration value name, going the other
direction. But I think it reads better starting with the value, and I
think that converting the value to a string (for use as the "name") is
slightly easier than converting the string to a value (though neither is
really that hard).
Pete
On May 13, 3:11*pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Tue, 13 May 2008 09:19:57 -0700, DotNetNewbie <snowman908...@ yahoo.com>*
wrote:
Hi,
I want to create a method that takes in the type of a Enumeration,
passes in the Enumeration as an object, and then outputs the values
with checkboxes, and pre-checks the checkbox if that value is set in a
mask.
This is what I have so far that outputs the values as a checkbox, but
I need to pass in *any* mask so it can check if that value is set in
the mask, if yes, check the checkbox.
What I would do is enumerate the Enum.GetValues( ) array instead of the *
GetNames() array. *Cast your mask and current value to int, and set the *
checkbox based on that result.
You could of course parse the enumeration value name, going the other *
direction. *But I think it reads better starting with the value, and I *
think that converting the value to a string (for use as the "name") is *
slightly easier than converting the string to a value (though neither is *
really that hard).
Pete
That worked great, thanks Pete! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Codex Twin |
last post by:
hello group:
The following is a fragment from a schema which defines the
EWethnicCategoryStructure type. As you can see, its type is defined by the
SimpleType enumeration EWethnicCategoryType.
EWethnicCategoryType is defined as a union with the CommonEthnicCategoryType
SimpleType enumeration.
Now when I use the XSD tool to create a C# class of this schema, the
resulting code does not include the SelectedEthnicCategory enumeration.
|
by: Claire |
last post by:
I have a large record with many enumerated fields.
The record is stored in a file and the fields have to be extracted.
I validate the data as it's read, but there's so many tests similar to the
following that I wondered if it's possible to create a single generic
function to perform the validation. Just to keep code size down if nothing
else. I'm not that experienced with .net yet so I don't know what's
possible.
example code
reader is...
|
by: orekinbck |
last post by:
Hi There
I am probably missing something fundamental here, but I cannot see a
method to search the values of a generic dictionary so that I can find
the key ? Of course I could enumerate through the Values collection
but that seems a little long winded.
I ended up using a sorted list because it has the IndexOfValue method.
However I don't need the sorting.
|
by: cipher |
last post by:
I have some constant values in my web service that my client application will
require. Having to keep server side and client side definitions insync is
tedious. I am trying to do something like this:
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };
However, the resulting wsdl omits the actual flag values:
- <s:simpleType name="Colors">
|
by: Ben Finney |
last post by:
Antoon Pardon wrote:
> I just downloaded your enum module for python
> and played a bit with it. IMO some of the behaviour makes it less
> usefull.
Feedback is appreciated. I'm hoping to provide a "one obvious way" to
do enumerations in Python.
> >>> from enum import Enum
> >>> day = Enum('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun')
| |
by: GU |
last post by:
How can one get a list of enumeration values for a given element in an
XML schema? I have been looking at the Schema Object Model, but I'm
making very little headway. Can anyone give me a nudge in the right
direction?
Specifically, I am using Actions Pane to assist in creating a WordML
document. For elements with enumerated values, I want to provide the
user with the list of valid values from the schema. For example, if I
have an...
|
by: JavaXMLDev |
last post by:
Hi
I'm new to XML schema work, but wondered how, if at all possible, can you specify a relationship between the values of an element's attributes.
Essentially I want context sensitive auto-complete for the attribute values of an element when creating an XML document.
I dont know how to define the relationship !
Scenario:
When using a location element and selecting the school
value for the type attribute I would like to restrict...
|
by: Satish Itty |
last post by:
How do I write the following c# code in vb
Product FindProduct(string code)
{
List<Productproducts = getProducts();
return products.Find(delegate(Product bo)
{ return bo.Code == code; });
}
|
by: raylopez99 |
last post by:
Here is a good example that shows generic delegate types. Read this
through and you'll have an excellent understanding of how to use these
types. You might say that the combination of the generic delegate
type expression in just the right place and a well-named method means
we can almost read the code out loud and understand it without even
thinking.
Note that since 'boxing' and 'unboxing' is involved (I think), you
don't get what you...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |