|
I'm currently writing a painting method of an custom usercontrol. Is there a way to determine if the control is in designing state or at useual (runtime state) ?
public void PaintObject()
{
if (DESIGNTIME == true) DrawRectArountControl();
else DoUsualDrawing();
}
|
|
|
|
|
Sure, try using base.DesignMode().
RageInTheMachine9532
|
|
|
|
|
public void PaintObject()
{
if (true == this.DesignMode) DrawRectArountControl();
else DoUsualDrawing();
}
|
|
|
|
|
please help me, i need change a permissions folder by code not manual,i mean where permissions saved in regedit
|
|
|
|
|
Take a look at FileIOPermission class.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
thank you for help me,but this class give me permissions on my application but not change permissions Physically on my drive i need to change the permissions on any folder on my drive Physically even if i close the application
|
|
|
|
|
|
What the problem really is, is that I wanted to store a function inside a namespace instead of a class, but that appearantly cannot be done. I have several very different classes witch all must use one function. I feel it would be waste of memory if I just drop the function to each class, or create an seperate class called something like MyFunctionsStoreClass that would store all the functions I might need. Is there an alternative ?
|
|
|
|
|
Yes, methods need to be inside a class. If you don't need an instance, you can add the word 'static' before the function declaration (like in 'static void blablabla()') and use it by calling ClassName.blablabla(), without the need for an instance.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
Thanks, that'll do the job.
|
|
|
|
|
In C#, yes. In IL, you can have global functions. I just include this for posterity. You're right about C#.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In VB.NET you can also have global functions.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
Hi Guys,
I'm new to socket programming. I need to create a C# program that reads data from multiple servers at the same time or one at a time - whatever is the easiest way.
I have more than a 100 ip address and ports (from the list), If I can't connect and read from the first (IP and port) the program should go to the next IP/PORT from the list and connect and read the data. After that all data retrieved will be saved into the SQL server database.
If you could redirect me to some tutorials or samples it would be of greate help. Or if YOU could help me I would appreciate it very much.
8-( Dabuskol
|
|
|
|
|
There is actually a pretty good simple "chat" example in MSDN. I would recommend downloading it. It also never hurts to get familiar with the System.Net namespace.
|
|
|
|
|
Tom,
Do you have any specific site from MSDN regarding CHAT? I'm sorry but I really need the answer because of the pressure from my boss.
Dabuskol
|
|
|
|
|
In my MSDN Oct 03, in ".Net Samples- How To: Networking" there is a sample simply called "Chat" with documentation and suplemental information. The exact same page is available online at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpqstart/html/cpsmpnetsamples-howtonetworking.asp
I found it simply by doing a search "chat". No divine inspiration...I just knew a chat example existed somewhere.
|
|
|
|
|
Hi Tom,
You're really great with your help.
I've already created a socket program in c# and it was working fine. I just need to trap certain events (errors) while my program is running. Since I have 50(s) or more connections in 1 time I need to monitor which one is not receiving any data for a couple of mins. What I will do is disconnect that particular connection and reconnect again until everything is ok.
Do you suggest any C# Networking Book becuase i'm planning to drop by the bookstore after office so that I'll have a better idea of this matter (first time on networking thing.)
Thanks and more power to you
/dabuskol;
|
|
|
|
|
Hi everyone.
I have been trying to remove a forms captionbar, but without much success. I have tryed setting the FormBorderStyle to None, but that removes the border as well as the Captionbar, but I want to keep the border as the 3D style. Anyone got any idea how this is done without a lot of coding?
Nightcrawler
Resistance is futile - Data (ST:First Contact)
|
|
|
|
|
As far as I know, this cannot be done. This "captionbar" and the border are tied together closely in Windows. However, you could draw the border yourself in an painting event (I guess). That case you must access the Windows (XP) theme, get the border, and draw it on the edge of your form. You must, however, somehow change the client area smaller that it is somehow (because the inside edges of the form are painted to be borders now, not client area). And don't forget to do manual painting for systems that doesn't support themes (anything else that Windows XP systems currently). There are a lot of examples how to use themes so you should have no problems if the main idea works...
|
|
|
|
|
Damn. Well thanks for a quick replay
Resistance is futile - Data (ST:First Contact)
|
|
|
|
|
Hi ppl!
May be you can help me with this:
I have some collection inside collection of my classes and I need to serialize it. The tree looks like this:
class NewsSourceCollection : CollectionBase, ISerializable
{
//This class is a main class and generally will hold all the data and List's
void Add (NewsSourceSingle in_param)
{
this.List.Add(new NewsSourceSingle(in_param));
}
void RemoveAt (int index)
{
this.List.RemoveAt(index);
}
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
//Question number 1: How I can serialize a List from System.Collection ???
}
private newsSourcesColllection(SerializationInfo info, StreamingContext context)
{
//Here goes deserialization
}
} //class close
class NewsSourceSingle : ISerializable
{
//This class will be used by NewsSourceCollection to Add or Remove from List and hold instance of NewsItemsCollection class to add some sub items there
private NewsItemsCollection m_ns;
public NewsSourceSingle ()
{
//c'tor
this.m_ns = new NewsItemsCollection ();
}
void Add(some_param)
{
this.m_s.Add(some_param);
}
.
.
.
.
+same functions to support ISerializable
}
class NewsItemsCollection : CollectionBase, ISerializable
{
//This class will hold all collection of NewsItems
+the same function for supporing ISerializable
}//class close
class NewsItems : ISerializable
{
string pp;
string dd;
+same functions to support ISerializable
} class close
Question number 2: I can Formatter.Serialize (stream,object) but I can not (!) deserialize it !! Why ? Because Assembly of my type 'NewsProg version=1.0.9.245 Token....' is not found !!?????
Question 3: How can I serialize List (of System.Collection) ??
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
First, read Serializing Objects[^] in the .NET Framework SDK.
If you attribute a class with SerializableAttribute , by default any private and public fields are serialized, so long as those types are serializable. Since you're deriving from the CollectionBase - which uses the ArrayList internally, which is serializable - your class is already serializable. You don't need to implement ISerializable unless you want to override serialization.
The second error is because the Type which is being deserialized is defined in an assembly that cannot be found. Make sure that when deserializing your assembly, your assembly can be found. See How the Runtime Locates Assemblies[^] in the .NET Framework SDK for more information.
For the answer to your third question, see the answers above. Mosts lists in the .NET Framework are already serializable. For example, the following creates an XML document with the content of an ArrayList :
using System;
using System.Collections;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Soap;
public class Test
{
static void Main()
{
ArrayList list = new ArrayList();
list.Add("One");
list.Add("Two");
list.Add("Three");
SoapFormatter formatter = new SoapFormatter();
using (Stream s = new FileStream("Test.xml", FileMode.Create))
formatter.Serialize(s, list);
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
how can I define ALT+X shortcuts for TabPages. Just inserting a "&" at the right place in the text-property like it works with buttons does not help. I didn't find a property.
thanks in advance
Gigiwig
|
|
|
|
|
I think you have to overriden OnkeyDown event of your form ans set the property of TabControl.SelectedIndex there.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Before that you should set your KeyPreview property of form to true.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|