|
Maybe use an ArrayList (from namespace System.Collections) intead of strings...
using System.Collections
Class1
{
private ArrayList _name=new ArrayList();
public Class1(){}
public string Name
{
get { return _name; }
set { _name=value; }
}
}
in this way this code
Class1 myClass=new Class1();
Console.WriteLine(myClass.Name[0].ToString());
will write on screen the first object stored converted to string... In this way you can store different types of data (or objects), since ArrayList class is supposed to store "object" objects :P
Obviusly you need to know what kind of data you are going to retrieve from the ArrayList... ^^
|
|
|
|
|
that didn't work, i've tried it... thanks anyway
|
|
|
|
|
Why don't you try property indexers. For eg,
<br />
class Class1<br />
{<br />
StringArrayClass cs;<br />
<br />
public StringArrayClass Name<br />
{<br />
return cs;<br />
}<br />
<br />
<br />
class StringArrayClass<br />
{<br />
public string this[int index]<br />
{<br />
return array[index];<br />
}<br />
}<br />
|
|
|
|
|
Yes! that's exactly how i did it.. I look on a couple of samples in msdn.. thanks!!!
|
|
|
|
|
Hi All,
I am wanting to Add some nodes to a treeview. I have a main node and have added a node under it which is fine but I want to add another node under my second level node. How can I do this? At the moment my new node I am adding adds at the second level and not the third level.
A sample, if possible, would be appreciated. I am reading in the data from an array.
Thanks in advance.
Stephen
|
|
|
|
|
An example:
<br />
TreeNode firstLevel = new TreeNode("First");<br />
TreeNode secondLevel = new TreeNode("Second");<br />
TreeNode thirdLevel = new TreeNode("Third");<br />
<br />
treeview1.Nodes.Add(firstLevel);<br />
firstLevel.Nodes.Add(secondLevel);<br />
secondLevel.Nodes.Add(thirdLevel);<br />
|
|
|
|
|
Anybody know of a quick and easy way to get the value of a custom attribute on an enum?
e.g.
public enum Example
{
[Url("http://www.AURL.com/")]
AnEnum,
}
I can do it using about three lines of convoluted code but I was hoping there was a nicer way. ta.
regards,
Paul Watson
South Africa
The Code Project
Pope Pius II said
"The only prescription is more cowbell. "
|
|
|
|
|
Paul Watson wrote:
I can do it using about three lines of convoluted code but I was hoping there was a nicer way. ta.
No
I use the following normally:
foreach (UrlAttribute ub in obj.GetType().GetCustomAttributes(typeof(UrlAttribute)))
{
}
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Dear Sir ,
I have a real problem when i deploy crystal report on any machine that only has .NET framework installed, but when the same project run on machine which has .NET installed it work proberly, i post Question before about the same issue and an expert send me link to MSDN to learn step-by-step how to deploy crystal report , and now after that all retries i have the same problem ..
When i run a progranm that has Crystal Report without making deployment it Generate "Commn language run time error" which an error i can't Understand it
at last i have a question : i want to be sure Which License Key must be provided to Properity of "Crystal_regwiz2003.msm" file :
C# .Net OR
Crystal Report for Visual Studio.Net
Sorry for my long Question
thank you ,
Shady Aly
|
|
|
|
|
I believe this needs to be the license key you get when you register the crystal reports.
|
|
|
|
|
Hi
I've used the article on making a compiler. It works and I can add assemblies ok eg. system.dll, but when I try to load microsoft.directx.dll which I put into the GAC myself it can't find it and I get an error C0006. I know the it is in the GAC and have checked that it is there. Whats wrong?
Thanks
|
|
|
|
|
|
Is there a way to prevent a program from throwing any exceptions at ALL to the windows operating system? Say I had a program that i wanted to run silently and never ever appear to the user.
Also, is there a way that I can have said program placed in a thread and killed at any time of my choosing? I am thinking specifically of some method from an object.
Thanks a lot,
Jim
|
|
|
|
|
Esmo2000 wrote:
Is there a way to prevent a program from throwing any exceptions at ALL to the windows operating system?
No. You can't control the execution of another application.
Esmo2000 wrote:
Also, is there a way that I can have said program placed in a thread and killed at any time of my choosing?
It creates it's own thread. You can't supply one for it. And, yes, you can kill the process at any time, but I don't recommend doing this. You run a much greater risk of destabilizing the system (more than it already is! )
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
And, yes, you can kill the process at any time, but I don't recommend doing this. You run a much greater risk of destabilizing the system (more than it already is! )
Now, I know what you mean and it is generally possible but I don't recall that I ever destabilized Windows (NT 4 and higher) by killing a process except for some cases where I was debugging some applications that used sub-classing (but in this case it was rather a bad API call than the process killing that destabilized the system).
Best regards
Dennis
|
|
|
|
|
If the process doesn't close nicely and it has unmanaged resources open, like most apps do anyway, those resources will suddenly find themselves orphaned. Kill enough apps like this and you'll evently run the system out of resources. Most of the time, if you do an End Process in Task Manager, the process will respond to the normal application shutdown messages. But if it doesn't, the process is then killed off using, shall we say, less than friendly methods.
Also, if the new process he launches launches other processes itself, those become orphaned.
It's just not a good programming practice...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
If the process doesn't close nicely and it has unmanaged resources open, like most apps do anyway, those resources will suddenly find themselves orphaned. Kill enough apps like this and you'll evently run the system out of resources.
You won't run out of resources in most cases. Any resource used by a process will be freed when a process terminates regardless of the reason for the termination, including the use of TerminateProcess()[^] (see Terminating a Process[^]).
Dave Kreskowiak wrote:
Also, if the new process he launches launches other processes itself, those become orphaned.
This is indeed one of the rare cases in which it would be a problem if the child processes don't exit on their own. However, if you really need to divide a solution in multiple processes the child processes should be able to handle the situation (the parent process might simply crash for example).
Dave Kreskowiak wrote:
It's just not a good programming practice.
I generally agree about that and definitely try to avoid it but if you want to automate a third-party tool (which could possibly be buggy), terminating the process might be the only possibility to handle certain situations.
Best regards
Dennis
|
|
|
|
|
Hello All,
please i need to know how can i put a checkbox in column in the datagrid control but with easy steps.in windows control not in webcontrol
please help
hay
|
|
|
|
|
|
Thanks about your reply but i need it with Windows control not in web control
|
|
|
|
|
When binding e.g. a DataTable to the grid you only need to add a column with boolean type to it. When binding the grid will automatically generate the checkbox style for the grid. If you are organizing the styles yourself you have to use the class DataGridBoolColumn. If your are not familiar with TableStyles and ColumnStyles you should read about them in the MSDN (they are rather well documented - search for DataGridTableStyle and DataGridColumnStyle)).
|
|
|
|
|
On occasion, I have problems restoring a Windows Forms appliction after it has been minimized to the taskbar. Clicking on the application on the taskbar will not restore it but right clicking on it and selecting Restore will. It has occured on multiple applications that I have written and does not happen every time they are minimized. Has anyone else experience this problem or have an idea what is causing it?
|
|
|
|
|
I have the menu similar to the IE Favorites
and want to display Tooltips with the url
when selecting the menuItem
ToolTip class is not capable to do that
Can anybody gimme a hand
Writing on C# in the VS2003
|
|
|
|
|
IE Favorites is not a menu, it's a ListView. In order to get something like that to work, you'll have to handle the MouseMove event of the ListView to keep track of the mouse coordinates on your control, handle the MouseHover event of the ListView and use the tracked coordinates in the ListViews' GetItemAt()[^] method to determine which item your hoverng over, then set the Toolip up with the text you need.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
But look
I've got the menu
where different links shown for each user
like
Bob -> LInk 1
LInk 2
Charlie - > LInk3
Link4
All this is done by the menu
And to provide a simple Tooltips on this menu
I should refactor all the code done, Like conver sub-menus
to list-views and display them in the proper pos
is it the easiest way???
|
|
|
|