|
Hi all, can someone please post an example of how to use the FlagsAttribute, specifically setting and unsetting the flags?
My code:
[Flags]
public enum StringFormat
{
Normal = 1,
Bold = 2,
Underline = 4,
Inverse = 8,
Color = 16,
}
In my class:
StringFormat format = StringFormat.Normal;
format = format | StringFormat.Bold;
What operators is needed to unset, for example, Bold? In the MSDN documentation they they have a Match() method. How does one use that?
Thanking all in advance
Cheers
READ MSDN
|
|
|
|
|
Since you are using powers of 2, the OR instruction is just like an ADD instruction. Therefore can't you just subtract?
I don't know how to make it display combinations... perhaps overriding ToString()?
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thx, thats exactly what i have now ended up doing, though it requires casting all members to int and then do the add, then cast back to enum type. Seems a bit like defeating the point thought The only thin that seems to work like I want it to is checking whether a flag is active by:
if ((format & StringFormat.Bold) == 0) etc...
to test for example if Bold is active.
Or maybe I'm just missing the point completely
Thx anyways
READ MSDN
|
|
|
|
|
Subtracting works, however it is nasty and generally not the way that you want to unset a flag. If you know that the Bold flag is set then you can use this to get rid of it.
<br />
format = format ^ StringFormat.Bold<br />
Note that this will toggle the Bold flag not erase it. So if it is set then it will unset it.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
Thx
jparsons wrote:
Note that this will toggle the Bold flag not erase it. So if it is set then it will unset it.
So if Bold is set "^" will unset it , and if Bold is unset "^" will set it?
READ MSDN
|
|
|
|
|
|
You can unset by doing:
format = format & (0xFFFFFFFF ^ StringFormat.Bold);
The second expression gives you a vector with every bit set except the bold one, and then when you and that with format, you're assured that it's cleared.
If you have [Flags] on the enum, when you call ToString() on it, you'll get a comma-separated list of the set bits.
|
|
|
|
|
thx all , at least i can progress on one area. Just to recap.
to unset: format = format & (0xFFFFFFFF ^ StringFormat.Bold);
to set: format = format | StringFormat.Bold;
Thanx again all
Now if only that damned richtextbox will start behaving
READ MSDN
|
|
|
|
|
Hi all,
I encounter 2 following issues with PropertyGird:
1. Adding a NumericUpDown control into a PropertyGrid.
2. I cannot show a property which is not a enumeration type under a ComboBox in PropertyGrid.
Please help me to solve these issues. Thanks.
|
|
|
|
|
Vu Truong wrote:
I cannot show a property which is not a enumeration type under a ComboBox in PropertyGrid.
You will need to implement a TypeConverter for your property.
Sorry I cant help you with Q1.
READ MSDN
|
|
|
|
|
How can I determine the handle of a radio box or a button on a webpage? When I tried using Spy++ it only gave me the handle of the page area and this class: 'Internet Explorer_Server'. Can anyone help?
|
|
|
|
|
All of the HTML input controls with the exception of SELECT are Windowless. You cannot use regular Win32 techniques to play with them. Rather you have to use MSHTML.
|
|
|
|
|
How do I use MSHTML?
-Neophit-
|
|
|
|
|
If you're really good with COM a quick search of MSDN for MSHTML will bring up all you need to get started. If you aren't all is not lost. You can achieve ~90% of anything you need to do with scripting.
If you explain what you're goal is i might be able to come up with a plan for achieving it.
|
|
|
|
|
I have two classes, let's call them MyClassA and MyClassB. The former extends a form and contains a listbox, the latter is more of a data class, containing an ArrayList.
As you've probably guessed by now, I want to fill my listbox in MyClassA with the contents of the array list in MyClassB. The array list contains regular strings.
In the constructor in MyClassA I've got:
public MyClassA
{
InitializeComponents();
myClassB = new myClassB();
myListBox.DataSource = myClassB.myArrayList;
}
Unfortunately this does not work and I can't figure out why.
My next step was to try the same thing using an array list in MyClassA as data source. This works fine and the listbox is updated whenever the array list is.
Could anyone please tell me what I've missed? Are there any special considerations to make when using another class' member as data source? Do I have to use events or such?
Thanks in advance for any help!
|
|
|
|
|
hello,
i'm trying to Upload dll's being generated on a Client machine(not ASP.NET)but rather UserControls and ComponentModel's. i'm getting lost in all the HttpWebRequest 'Post' and HttpPostedFile stuff. the later looking like its almost purely for ASP.NET.
any advice would be great?
Orion
|
|
|
|
|
just to be clearer, sorry.
presently the dll's are being saved on the client. i can get to them no problem. its sending them across the wire that's a problem.
i keep thinking HttpWebRequest is the way to go because i can state the URI. and in this case the files are going to a virtual directory. although its the content type that's got me since these are not text files.
thanks,
Orion
|
|
|
|
|
Does anyone know how to make the Progress Control flat? and change the background colour and, if it not toooooo difficult, the colour of the bar?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
There is a good premade one if you look under C# controls on this site.
|
|
|
|
|
are you talking about the System.Windows.Forms.ProgressBar ? because thats the one im using, im just having trouble changing its colours.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
http://www.codeproject.com/cs/miscctrl/progressbar.asp
|
|
|
|
|
|
Hi all...
I'm in the process of writting a little app to control my NT servive as it runs on our server farm. There are going to be lots of machines running and having to manually configure each one will be a pain in the arse, thus my question...
Given that I already have a ServiceController object and looking at Service X on machine Y, how do I get back/alter the startup mode of that service. I have found the ServiceInstaller object but am unable to get it to populate with the info for the service I am looking at in the ServiceController object...
Any ideas?
Thanks
Pete
|
|
|
|
|
What, no one knows! All is lost! Fires of HELL!
Please help meeeeee!
Pete
|
|
|
|
|
Hi
I want to develope an client application to update/retrieve data from a remote database namely SQL on some maching over the Internet. For example, application to connect to TheCodeProject database to retrieve the appropriate data, format it then output it. In the essence, it just acts like off-line forum reader , without having open the browser and offer some extra functionality like saving, attaching files, etc.... However i m still in the dark of how about to do it. I would like to ask some questions related to the matter:
1) Is C# the most appropriate language to do this?
2) What sort of configuration does the MySQL server needs to apply for my application to make a connection?
3) I want to make the interface of the application Outlook liked, how would i do so?
Thank alot for reading this and looking forward to receive your enlightment!
Best Regard
|
|
|
|