|
You should use properties when you are dealing with storing the data in a private variable.
You should use Get/Set methods when that data is NOT being stored cannot be accessed as quickly as a "return myPrivateData;". Some applications of this type would be retreive the customer name from the database; return all the prcoesses running on the system, etc...
The line is a fine one and its quite elastic so just go with what feels right
James
Simplicity Rules!
|
|
|
|
|
Stick with Properties when appropriate.
The Property Grid likes them, the debugger likes them, and Serialization likes them.
Go with the flow, it will make your life easier...
Regards
|
|
|
|
|
Hi All,
Quick question here, I need to check to see if a cookie exists when someone enters 1 of my pages.
This is an intranet so I know that everyone accepts cookies but is there way to see if a certain cookie exists?
Thanks,
Gavin
|
|
|
|
|
Check the cookie for null
James
Simplicity Rules!
|
|
|
|
|
Tried that,
for some reason the page falls over if I try the following
if (HttpContext.Current.Request.Cookies["NewOutbreak"]["Test"] == "")
{
//Do Something amazing
}
else
{
Go home
}
I get an error saying something like cannot check for null as it doesn't exist.??
|
|
|
|
|
I wonder if you are getting the error from the "NewOutbreak" cookie not existing and then trying to access it.
Give this a shot...
<br />
Request r = HttpContext.Current.Request;<br />
if(r.Cookies["NewOutbreak"] == null)<br />
{<br />
}<br />
else if( r.Cookies["NewOutbreak"]["Test"] == null)<br />
{<br />
}<br />
else<br />
{<br />
}
I'm still working out your issue at the top
James
Simplicity Rules!
|
|
|
|
|
werkin
I see the logic, you have to check to see if the Cookie exists before checking to see if the cookies key exists or has any data...
Seems to be 100% Thanks
|
|
|
|
|
Hi,
How do you make a text box on a windows form accept numbers only?
These is really easy in VC++ 6.0, can't be hard in C#
Cheers
Ollie Riches
|
|
|
|
|
there's already a thread about that problem in this forum (currently on the next page)
:wq
|
|
|
|
|
I know two way for it.
One:
http://www.codeproject.com/cs/miscctrl/maskedcsedit.asp
Two:
Handle KeyPress event of text box yourself:
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar < 48 || e.KeyChar > 57 )
e.Handled = true;
}
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
The Answer is...
http://www.codeproject.com/script/comments/forums.asp?forumid=1649&select=160478&fr=51#xx159561xx
|
|
|
|
|
Magic is a fee source code user interface library for .NET
Now includes completely rewritten docking code that allows...
multiple docking windows in same column/row
multiple docking windows in same floating form
multiple content in same docking window
save/load docking configuration
MDI support in the MenuControl via a pendant
Numerous bug fixes
http://www.dotnetmagic.com
PS. I could not find an annoucement board as the proper place to put this. Is there one I have missed?
Phil Wright
phil.wright@dotnetmagic.com
|
|
|
|
|
Phil Wright wrote:
PS. I could not find an annoucement board as the proper place to put this. Is there one I have missed?
Good attempt at naivety
But it didn't work pal, not even a little
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Good works realy.
aspecially for docking one of the best solution i've seen.
Continue.
Continue to let it free.
Phil Wright wrote:
PS. I could not find an annoucement board as the proper place to put this. Is there one I have missed?
You must write an article and quote your site.
i thinks programers believe it's commercial if u didn't (boring after all you efforts)
thanxs
|
|
|
|
|
I created a custom control derived from a panel in which I added flat buttons but how can I add action on the buttons dynamicly ???
I can't because the class is derived from a panel.
Anybody can help me ?
|
|
|
|
|
You could expose your buttons via a property as a collection (of buttons). But then you are exposing everything about the buttons.
|
|
|
|
|
Doh! Then again, there is nothing stopping you from accessing the built-in Controls collection of the Panel and attaching an event handler dynamically.
|
|
|
|
|
You can expose event properties on your control; like so...
public EventHandler ButtonA_Click
{
add
{
buttona.Click += new EventHandler(value);
}
remove
{
buttona.Click -= new EventHandler(value);
}
} You wind up with having to name the events something different, but you can control what events are available.
HTH,
James
Simplicity Rules!
|
|
|
|
|
The problem is that I create only one instance of a button and Each I wrote tb.AddItem("Test",Color.Black,Color.White,0); (that's an example)
the control add a button itself to the parent control which is a panel.
so how can I handle all the buttons actions when I have only one Button Instance ??
can I make a function like ItemClick(int index,EventHandler action) ??
if yes can u plz give me some code because I try to use this with a switch statement and I got an error :
"a value constant is expected"
Thanks
|
|
|
|
|
I'm having a hard time making out what you are trying to do so let me know if what I suggest answers a different problem.
What I think you're having a problem with is you only have one real button, but you have multiple click events that need to fire.
Using the event handler I described above works fine; it properly handles firing of chained events (multiple methods to run when one event fires).
I'm unsure what your ItemClick function is meant to do though; can you describe in words or psuedo-code what it would do?
James
Simplicity Rules!
|
|
|
|
|
I found it, I just added Envet Handler to my AddItem declaration
|
|
|
|
|
Hi,
Does anyone know how to retrieve the width of a string if outputted to the screen in a given font, e.g. Arial 12 and the string "Hello World"? In other words, how many pixels wide would that string (or any given string) be on the screen?
Thanks!
--
Andrew.
|
|
|
|
|
The graphics object has a MeasureString method which returns the size of the text.
You pass in the string and the font object to measure with. There are a few other parameters that can be used to adjust how the text will be rendered (the StringFormat class).
James
Simplicity Rules!
|
|
|
|
|
Thanks mate! Just what I needed . Now just what I need is some sleep !
Thanks again,
--
Andrew.
|
|
|
|
|
hello james..thanks for ur help.
but saddly it didn't work.
the method Add() must take a string or a ListViewItem ..
i hope we can get a better solution..thanks ))
shadowman
|
|
|
|