|
foreach(object item in listBox1.SelectedItems)
listBox2.Items.Add(item)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You could also do;
ListItemCollection LIC = new ListItemCollection();
LIC = ddl1.Items;
foreach(ListItem listitem in LIC)
{
ddl2.Items.Add(listitem);
}
|
|
|
|
|
Hi.
let's say i have the following code:
int x;<br />
...
if ((x == 1) || (x == 5) || (x == 7) || (x == 9))<br />
{<br />
... /some code<br />
}<br />
is there an elegant way to code it without repeating the x object? i thought about something like:
if (x == (1 || 5 || 7 || 9))
Thanks
|
|
|
|
|
not really, other than
switch(x)<br />
{<br />
case 1:<br />
case 3:<br />
case 5:<br />
case 7:<br />
break;<br />
}
but this is more longwinded than the aforementioned if (x==1 || x==3 || x==5 || x==7) method
|
|
|
|
|
Hi,
another possibility:
if (Array.IndexOf(new int[] { 1, 5, 7, 9 }, x) >= 0) {
}
If you store the array in some field it would be shorter (and more efficient when called often):
private int[] _goodNumbers = new int[] { 1, 5, 7, 9 };
if (Array.IndexOf(_goodNumbers, x) >= 0) {
}
Robert
|
|
|
|
|
Hi, there
I've created a window application consisting of one form, one user control, and 3 classes.
After building it, I tried running the exe file directly and it worked fine.
However, when I closed my application, the application form was closed correctly but it still stayed in the process list (seen from the window task manager).
When I tried running it again, another process of the same name appeared in the process list.
Running it multiple times brought up multiple processes.
I believe that's because the application is not really terminated.
I also made sure that all instances of the classes are disposed by inheriting them from IDisposable and calling GC.SuppressFinalize(this) in the Dispose() method.
Anyone got any idea about this?
Please help me fix it or my application will eat up all the user's resources. T-T
Thank you very much.
KiT
|
|
|
|
|
which IDE are you using? vc# 2005 express does start a ApplicationName.vhost.exe when opening the solution and restarts the process if you kill it manually - try to kill it manually and check if it is started again :P
|
|
|
|
|
I'm using VS2005 and it does start AppName.vhost.exe.
Killing each process can really terminate the app.
However, that's what I need to solve: not to have to end it manually.
Thank you very much.
KiT
|
|
|
|
|
Hi,
The reason you're probably having this is because you're calling GC.SuppressFinalize(this).
From msdn:
GC.SuppressFinalize Method
Objects that implement the IDisposable interface can call this method from the IDisposable.Dispose method to prevent the garbage collector from calling Object.Finalize on an object that does not require it.
I'd advice against implementing IDisposable if you aren't using unmanaged resources or threads anyway, the garbage collection usually handles itself quite well anyway. Good luck!
|
|
|
|
|
I've tried removing all the implementation of IDisposable.
However, it doesn't solve the problem.
Thank you very much.
KiT
|
|
|
|
|
Are you creating any threads by yourself? If true, you need to set the IsBackground[^] property of those threads to <code>true</code>. Otherwise, those threads will remain alive and will prevent your process from dying.
|
|
|
|
|
did you tried application.end
this usually happens when you call some form from another form and just hide the base form
or some thread in back ground is still working
it will be a better option to debug your application
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
I have only one form and not calling any other forms.
But I do calling some classes and a user control.
Where to set Application.end?
Thank you very much.
KiT
|
|
|
|
|
at formclosing event or where ever you want to close your app
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
I've run into similiar circumstances. I have the forms running on seperate threads and I also have a thread running a formless message loop. When the form closed, the application didn't shutdown because the other thread was still running. Try calling Application.Exit() when the form closes. It's probably not that simple, but I'd thought I'd pass on my 2-cents worth.
|
|
|
|
|
|
|
Hi Senthil,
I have the same problem, but the ScrollToCare method you have suggested has no effect (or not what I hoped to do)
This code snippet should place the cursor always at the current position
but it does not scroll to the end of the lines.
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
try<br />
{<br />
this.richTextBox1.Clear();<br />
for(int i=0; i<200; i++)<br />
{<br />
this.richTextBox1.SelectedText = "Index = " + i.ToString() + "\r\n";
this.richTextBox1.ScrollToCaret();<br />
}<br />
}<br />
catch{}<br />
}<br />
What's wrong ?
Tnx in advance
Regards
Frank
|
|
|
|
|
Does anyone have a particle filter for tracking objects in avi, mpeg files?
|
|
|
|
|
Plz try to answer my question
|
|
|
|
|
Please try to ask a question, concisely, and without the use of txtspk.
|
|
|
|
|
i asked what is the difference between cloaning and copy
|
|
|
|
|
Ravi Shankar43 wrote: get me the answer for that
I understand english is probably not your first language, but you must speak it well enough to realise how rude that statement is.
Your question is not particularly clear - often the case when you use 1 line questions! Programming asside, cloning and copying are the same thing. The definition of clone[^] includes "An exact digital copy, indistinguishable from the original".
In .NET you have an interface named ICloneable which defines a way to clone an object... that is to make a deep copy. Your use of the word Copy, may imply a shallow copy.
As I said - your question is mighty vague!
|
|
|
|
|
I am new to this group.And thanks for your reply.
|
|
|
|
|
hi
i have 2 programs and want to add a listviewitem from the one program to a listview in the second program.
with listboxes this is kinda easyly done with sendmessage and LB_ADDSTRING.
but how can this be done with a listview/item ?
googled for some hours now and didnt find a solution.
thx in advance
|
|
|
|