|
If you do a Thread.Sleep the rest of the application will not be loaded. Why don't you try something like that
<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
....<br />
Form2 frm= new Form2();<br />
public Form1()<br />
{<br />
Thread thread = new Thread(new ThreadStart(StartForm2));<br />
thread.Start();<br />
frm.Close();<br />
}<br />
<br />
private void StartForm2()<br />
{<br />
if (frm != null)<br />
frm.ShowDialog();<br />
<br />
}<br />
....<br />
}<br />
|
|
|
|
|
if you look back at my code you'll see that the Thread.Sleep(1500) is just to pause for a second.. i know nothing is going to happen during that time..
right above that is where i load all of my stuff.. i just pause so that the splash screen is showed for at least a second, it serves no other purpose and can be removed. this is all in my constructor for my main form..
what is the benefit of creating a thread just to show and close the dialog when you could just show and hide the dialog around the section of code that does your loading?
AboutBox myAboutBox = new AboutBox();
myAboutBox.Show();
myAboutBox.Refresh();
Thread.Sleep(1500);
InitializeComponent();
myAboutBox.Hide();
myAboutBox.Dispose();
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
I'm sorry if I'm offended you I didn't want to criticize your code.
What I'm saying is if that guy wants to show a form during the load of the real application, in my opinion is better to show it in a different thread because it guarantees that the form will be shown and you will not get a blank screen because the application is busy doing other things. But of course you can also use tricks like Refresh() or Application.DoEvents() doesn't matter.
|
|
|
|
|
ah.. i was wondering why i had to refresh the form to make it show.. i guess i can see how having another thread could help them both.. especially if you wanted your loading form to have some sort of animation or something.. btw, i wasnt offended, i honestly wanted to know the purpose
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Thanks guys for your replies.
Jose, when I try to close the "start" form, the main form losts focus. Any ideas how to dial with that?
------------------------
Andrey
|
|
|
|
|
my guess is that if you just called Focus() it would get focus back
Form1.Focus();
thats my guess
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
i have a listbox and a button.. when you click on the button i want to remove what is selected in the listbox, but i need to be able to tell if something is selected in the box or not..
if (this.lvSDeduc.SelectedItems == null)
{ MessageBox.Show("You must select something to remove before clicking the remove button.");
return; }
ListViewItem objItem = this.lvSDeduc.SelectedItems[0]; this doesnt work, so when it gets to the SelectedItems[0] i crash since there is nothing selected.. any suggestions?
thanks in advance!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
use this code
if (this.lvSDeduc.SelectedItems.count == 0)
{ MessageBox.Show("You must select something to remove before clicking the remove button.");
return;
}ListViewItem objItem = this.lvSDeduc.SelectedItems[0];
i think it will work
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
doh, should have thought of that one thanks a ton!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Try this in your button message handler:
string sSelectedItem = m_ListBox.SelectedItem.ToString();
if( sSelectedItem != null )
{
m_ListBox.Items.Remove( sSelectedItem );
}
Hope this helps
|
|
|
|
|
does anyone know how to prevent that "do you wish to send this mail?" dialog that appears when sending documents via crystal reports??
//Roger
|
|
|
|
|
Something kind of puzzled me quite a while ago and has came back up again (just like eating KFC Chicken, taste that stuff for three days). Why exactly does it matter to declare a delegate outside a class definition instead of just declaring it inside the class?
Rocky Moore <><
|
|
|
|
|
Well, a delegate is a class. So, if you declare a delegate DelegateType inside a class ClassType, you will have to reference it via ClassType.DelegateType instead of just DelegateType, if you are referring to it from outside the class.
|
|
|
|
|
Yes, that is the obvious, since it is nested it must be referenced with the class it is defined in. Is that the only reason though? That is the actual results I like, since it pertains to the class I like have it contained in the class.
Rocky Moore <><
|
|
|
|
|
Rocky Moore wrote:
That is the actual results I like, since it pertains to the class I like have it contained in the class.
And you can mark it internal etc to hide to implementation. Personally I keep delegates outside types, but mark them internal.
<a TITLE="See my user info" href=http:
|
|
|
|
|
I’m trying to scrape a site but I’m having a problem.
My program works for 4 iterations and then stops. I ported this code, line for line, over to Perl and it works fine.
I stepped through the C# code and found that it hangs on this line:
objStream = wrGETURL.GetResponse().GetResponseStream();
But it only hangs on the fifth time, it works for the first four times.
This is baffling me, so I'm hoping one of you guys can figure out what is wrong.
e") != -1)ThisOne = true;
}
}
Console.ReadLine();
}
}
}
|
|
|
|
|
Try an "objReader.Close();" before it goes out of scope.
(If this message is posted twice, sorry.. CP gives me all kinds of fits about posting message. It errors out about 50% of the time. Never know if it got posted until I see them actually appear.)
Rocky Moore <><
|
|
|
|
|
Thanks Rocky,
That did the trick.
|
|
|
|
|
Hi,
I run your code. In my first trial , after a time , it seemed to be stopped. Yes it was at index 4. Later i decided to debug your code and it worked well. Later i made it run without debugging, guess, it worked well again.
That means that there doesn't seem to be a code problem.
Cheers,
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
how to add EventsTab on PropertyGrid and after
programmaticaly switch between Properties/Events tabs?
|
|
|
|
|
;PHi,everyone,
I wanna add some document with detail style(such as Bold,color and size of font and so on) into my database. Then I can show these documents through HTML, Now I don't know how to store the rich text in SQL Server, also, I don't know how to display them in Pages by JSP programmes.
Can you tell me? Or give me some hints. Thanks a lot.
Yours,
Sincerely,
Ken Zhu
|
|
|
|
|
Please, any one can help
i want to display flash movies in c# forms but i cant do it.
|
|
|
|
|
there can be other means, but the simplest i can think off, is to host IE web control in your form and feed it with html which has your flash movie.
Cheers,
Kannan
|
|
|
|
|
Dear gurus,
I am adding "\n" to a string, not working.
Do I use "Convert.ToChar(some int here?)" ?
Thanks so much
Khang Nguyen
|
|
|
|
|
Try "\r" for a carriage return, "\n" for a newline.
|
|
|
|