|
dipuks wrote: List<string> myList = new List<string>;
That doesn't even compile. It should be:
List<string> myList = new List<string>();
As Scott pointed out, the exception does not occur in the scenario that you describe. It's hard to find a problem in the code that you are using, when you are posting some other code that you are clearly not using...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
I think the reason why your second insert is not working because index 1 is not yet created.
Maybe try to use add instead of insert then sort the content of the generic list.
Your code is not compiling because you have a missing parenthesis in instance creation of generic list.
List<string> myList = new List<string>();
Regards,
|
|
|
|
|
Hi,
i heard here in the forum about killing objects.
What is the advantage to me of doing so? free ram?
if a have a string object (or other) and i know i won´t use it anymore can i kill it? what in for me? ram? how to kill it?
thanks
|
|
|
|
|
Objects are reference counted in C#. The only thing you need to worry about killing are objects that have a Dispose method.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi,
I have been making some C# + SQL server applications.
I display and edit data in the same forms/pages.
I know i can make it prettier using crystal reports.
What is the best article here in code project about crystal reports or a good free tutorial to download in the www?
Thanks
|
|
|
|
|
It is possible to find good articles, but most helpful one is the Crystal Reports' own help file.
I suggest reading that one first.
www.businessobjects.com also has many samples that can be downloaded.
Good luck...
|
|
|
|
|
hi
i wanna know how do u retrieve information about system through C#
thanks
|
|
|
|
|
You didn't say exactly what information you want to get. So this will give you just about everything.
using System.Reflection;
. . .
Type t = typeof(System.Windows.Forms.SystemInformation);
PropertyInfo[] pi = t.GetProperties();
for (int i = 0; i < pi.Length; i++)
Console.WriteLine(pi[i].Name + " = " + pi[i].GetValue(null, null));
Cheers!
Marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|
|
|
I need to create an instance of FileSystemEventHandler inside a function, using a parameter passed into that function. FileSystemEventHandler takes an Object type that represents the method called by the FileSystemEventHandler delegate.
This would be easy with C++ since I can use a pointer to a method, but I'm lost in how to do it in C#. How can I pass this into my function so I can create the instance?
For example: Where OnChanged is the method for the delegate to call.
private void CallingFunc()
{
MyFunc(OnChanged);
}
private void MyFunc(SomeType theMethodToCall)
{
FileSystemEventHandler(theMethodToCall);
}
TIA
|
|
|
|
|
Not Knuth wrote: // ? what type do I use as the input parameter here?
I can't tell what you are trying to do but maybe you could use FileSystemEventHandler as the parameter type. Also just guessing here but you may have a design issue. Can't really tell based on your post because:
Not Knuth wrote: private void MyFunc(SomeType theMethodToCall)
{
FileSystemEventHandler(theMethodToCall);
}
that just doesn't make any sense because you would be creating a handler that is not registered with any event so it's pointless.
led mike
|
|
|
|
|
I was trying to keep the code sample simple. Maybe too simple!
This is part of a class that wraps FileSystemWatcher to provide some other functionality that is needed. The situation with the arg for this method arises because I need to be able to set the method(s) to be called by the delegates for the instance of FileSystemWatcher that is wrapped in the class.
Thanks for trying to make sense of my sample code!
|
|
|
|
|
Not Knuth wrote: This is part of a class that wraps FileSystemWatcher
so then that should work yes?
private void MyFunc(FileSystemEventHandler handler)
{
fileSystemWatcher1.Changed += handler;
}
led mike
|
|
|
|
|
Yes. It works perfectly. And it's very obvious... now that you point it out!
led Mike comes through again! Thank you.
|
|
|
|
|
Hi
I am using Visual Studio 2005 to create a Windows Application. I am struggling to move controls at runtime using the mouse.
I works fine when the Control (panel1) is directly on the Form, but when the Control is on another panel (panelGrid) on the Form it does not work well.
I use the following for the MouseMove event:
private void Control_MouseMove(object sender, MouseEventArgs e)
{
Control control = (Control)sender;
if (dragging)
{
Point location = new Point(e.X, e.Y);
location = control.PointToScreen(location);
location = PointToClient(location);
location.Offset(dragOffset);
control.Location = location;
}
}
When the Control is on another panel and not directly on the Form it jumps when I start moving it with the mouse.
I think it is probably the following lines that needs to change:
location = control.PointToScreen(location);
location = PointToClient(location);
I tried the following but it made it even worse:
location = control.Parent.PointToClient(location);
Can anyone throw some light on this for me please.
Thanks
Kobus
|
|
|
|
|
Using VS2005 on Vista...
I have the following
#if DEBUG
System.Diagnostics.Trace.WriteLine("block of code starts");
#endif
code
code
more code
#if DEBUG
System.Diagnostics.Trace.WriteLine("block of code ends");
#endif
Sometimes, both trace statements show up in the output window, sometimes they don't. The code in between does not present an early exit point of any kind, so I fully expect both trace statements to be displayed.
Is there something dodgy about .Net's ability to trace?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
A while ago I experienced the same kind of problem. In my case it was because two different threads affected each other, eventually blocking trace window once in a while (this might not be true in your case).
However, I created my own trace listener which only collected trace messages to a static generic list and used lock in order to prevent lost messages.
Hope that this helps you,
Mika
|
|
|
|
|
John Simmons / outlaw programmer wrote: #if DEBUG
If you are trying to execute in Debugging session use System.Diagnostics.Debug.WriteLine etc. Tracing is a different purpose altogether. I don't know if this will solve your problem, I'm just saying.
led mike
|
|
|
|
|
I have xml file like;
<Service>
<argument>12345</argument>
<interval>500</interval>
<source>test1</source>
<source>test2</source>
<source>test3</source>
<Service>
How can i remove selected "source" node. For example; I list the value on listbox, user select test2. How can I delete "test2" node in xml file.
Best Regards...
|
|
|
|
|
Assuming you loaded the file into an XmlDocument and populated the ListBox with the source nodes...
doc.DocumentElement.RemoveChild ( listbox.SelectedItem ) ;
Then save the file again.
I haven't tried it, but I hope that's not too far off.
|
|
|
|
|
I need some help getting a date range of 30 days Including the current date to display in a list view box. The first line would displays today's date, the second would display tomorrows, so on and so forth. In the end the second column in the list box would display an event that was set to trigger that day. you will be able to double click the date and setup or edit the event on that day. But the events themselves will be handled by another function. This is just purely to see the next 30 days (Because we'd never have more than that.) And the name of the event on that day.
My Current code
class datetime
{
string sTemp = DateTime.Now.ToString("yyyy-MM-dd");
TimeSpan m_Time = DateTime.Now - DateTime.Now;
DateTime m_EventStartTime = DateTime.Now;
m_Time = DateTime.Now - m_EventStartTime
}
I haven't figured out how to specify that I want 30 days, nor have I figured out how to get it to call correctly into the List box.
can anyone give me some help please?
Removed: You must either be really ambitious or completely off of your rocker.
Me: I've been off my rocker for years now
|
|
|
|
|
Hi,
Could you simply loop the desired amount of dates and add them to listview? For example:
for (int i = 0; i <= 30; i++) {
this.listView1.Items.Add(System.DateTime.Now.AddDays(i).ToString("yyyy-MM-dd"));
}
Mika
|
|
|
|
|
How do i implement shortcut keys in VC#. i.e, if somebody keys in Alt+A, a new form should open
Its not the will, its the wish which drives fortune!
|
|
|
|
|
Have a menu item (or similar) to open a new form and assign Alt+A to it.
(You can set the menu item to be invisible if you like.)
|
|
|
|
|
that's what i want to know...how to implement that "alt+a"
Its not the will, its the wish which drives fortune!
|
|
|
|