|
You have created a new ListBox in the listBoxStudentat_SelectedIndexChanged method, but at the end of the routine you have let it get lost. You need to create a ListBox on your form and add the items to that. Are you sure you want to add items just at the point that the ListBox selection changes?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Yes, I want that my listbox has to show every line from text file, and also, I don't want that to get lost.
|
|
|
|
|
Then you need to initialise it at the beginning of your program, not in the event handler for selection change. Just read the file and add each item from the file into the listbox that is on your form, don't create a new one that is not connected to anything.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
So you are saying that I nedd to create a text file only once, and after that i can manipulate with file details in my form calling them.
Am I right or...
|
|
|
|
|
dr_iton wrote: So you are saying that I nedd to create a text file only once, No, I did not discuss creating a file, I was explaining how to fill your ListBox .
dr_iton wrote: and after that i can manipulate with file details in my form calling them. Sorry, I have no idea what that is referring to.
Your application should be something like:
- During initialisation read your text file and build the
ListBox from its contents. - As information is added or changed in the application you may make changes to the
ListBox . - At program termination you should save the items from the
ListBox if it has been modified. - Other processing as required.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I got the point now.
If I can not post a solution tonight because I'll be busy, tomorrow I'll tell you if I solved my problem.
Once again thank you for your reply.
Cheers.
|
|
|
|
|
Hi everyone
could you explain about GetProcessesByName,I saw MSDN but I could'nt understand
is it true? GetProcessesByName same with GetProcessById ? GetProcessById needs to a PID and return a process but GetProcessesByName needs to process name(its really process name or application name?) and return arrays of processes
|
|
|
|
|
The MSDN text is pretty clear - you feed it the name of the executable file, and it returns al the processes that are currently running from that file:
Process[] procs = Process.GetProcessesByName("chrome");
Will give you a list of all the processes
running the Chrome browser.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
What are the most likely culprits to this error ?
The semaphore timeout period has expired.
The port in question is a simple BlueTooth USB plug-in thing, which Win'7 sees properly and everything.
This is a "sometimes" error. It is not consistent, and I have not found it documented on MSDN or other sites.
This is the dozen line method I'm using...
public static void Open_ActivePortWeWillUse(String Drone_StringNameFromUser)
{
SerialPort TempSerialPort = new SerialPort(Drone_StringNameFromUser, (int) SerialPortSpeed);
ThePorts.ActivePort1 = TempSerialPort;
ThePorts.ActivePort1.DataBits = 8;
ThePorts.ActivePort1.Parity = Parity.None;
ThePorts.ActivePort1.StopBits = StopBits.One;
ThePorts.ActivePort1.DataReceived += new SerialDataReceivedEventHandler(OurBackGroundSerialPortReceiver);
ThePorts.ActivePort1.Open();
}
modified 22-Dec-12 22:07pm.
|
|
|
|
|
I tried the same sample in VS2012 and the code works but the problem is VoiceChat doesnt work proper. Voice conference ports are not open thus the list of clients for voice conference are not added. No voice conference????
Thread: Voice and Text Conferencing Library[^]
|
|
|
|
|
Don't post this here - if you got the code from an article, then there is a "new message" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
I have added a login in screen to my program which works great except if the user just closes the login window it bypasses the the screen and loads the program. Is there a way to prevent this? Here is a sample of the code:
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
private void Button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Button1_Click(object sender, EventArgs e)
{
if ((textBox1.Text == "puppy") && (textBox2.Text == "password"))
{
MessageBox.Show("Welcome Puppy", "Success",
MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Dispose();
}
else
{
MessageBox.Show("Wrong username or password","Invalid Input",
MessageBoxButtons.OK,MessageBoxIcon.Error);
}
|
|
|
|
|
Easiest way is to have a LoggedIn property in your form. Default it to false, then set it to true when he logs in correctly.
When you get back to the main form, check it, and behave appropriately.
BTW: Don't Dispose your form from inside - use Close instead. You can't dispose it until you have finished and the there is still and instance reference in the main form!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
There are many ways to protect this.
However if you want to go for simplicity you can use a global bool for this.
Example:
public bool LoginStatus;
Then an example of usage:
!LoginStatus means basically if false.
LoginStatus means true.
So you set this bool in your login part to true if login is ok.
By using:
LoginStatus = true;
public void YourLogin()
{
if(!LoginStatus)
{
}
else
{
}
}
As said above this is a very simple way to do it.
There are lots ways more to do this.
|
|
|
|
|
Never recommend public fields - always use properties. Remember that a lot of the questions (like this one) are from complete beginners, and it is best to get good habits ingrained as early as possible!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
The way I've always done this is by using a DialogResult from the login form. In the login form's "Button1_Click" event handler, where you have verified that the login info is correct, instead of "this.Close();" use "this.DialogResult = DialogResult.OK;" And then to use it, go to the Program.cs file. In the Main method, remove "Application.Run(new MainForm());" and replace it with:
LoginForm login = new LoginForm();
if (login.ShowDialog() == DialogResult.OK)
{
Application.Run(new MainForm());
}
That is, unless you want the user to "log out" and see the login screen again. But in this case, if you don't need that functionality, this will show the main form ONLY if the dialog result is "OK". It eliminates the need for a property (global or otherwise). Do you see what I'm doing here or do you need more explanation?
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
This worked perfectly, thank you.
|
|
|
|
|
I am trying to do a preliminary evaluation of Parallel Tasking in C#. I ran this script on my local. Each time the count of files seems to be different.
http://msdn.microsoft.com/en-us/library/system.io.directory.getfiles(v=vs.71).aspx[^]
A few outputs are:
Processed 14062 files in 715 milleseconds
Processed 14092 files in 710 milleseconds
Processed 14080 files in 695 milleseconds
Processed 13908 files in 712 milleseconds
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
I think you link points in teh wrong direction - it goes to a simple description of Directory.GetFiles with trivial examples (.NET 1.1) or the leader page for the various overloads (.NET 4.0) - neither of them should find anything like 14K files in the root directory of your boot drive (or someone really needs to learn about hierarchical data storage)
Nothing I can see relates in any way to parallelism - so post your actual code fragment that generates the result you show!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
|
Vasudevan Deepak Kumar wrote: Is there an issue with this script?
That would be unlikely. More likely is that the app hits an exception, and with the tasks executing in parallel, it'd abort after a number of times.
Try a different path; in the Program Files folder there'll be paths that you don't have access to, files that are locked and more.
--edit
The results of my three consecutive runs;
Processed 11714 files in 106908 milleseconds
Processed 11718 files in 105843 milleseconds
Processed 11714 files in 103945 milleseconds
If you want to know "what" files were added/removed in the meantime, then simply write the filenames you encounter to a text-file. Use a tool like "WinDiff" to visualize the differences between those text-files.
modified 13-Dec-12 12:55pm.
|
|
|
|
|
как програмист не умер когда над ним эксперементы ставят, вот и живи как хочешь в этой стране
|
|
|
|
|
I'm sorry, but could you please ask questions in English? This is predominately an English language site and we can't help you if we don't understand you. When I ran this sentence through Google, it translated it to
"as a programmer is not dead when put on him experimenting, and that's how you want to live in this country"
That's no help to me in working out what you are after.
|
|
|
|
|
Some people are shy to do a question :P
|
|
|
|
|
This is the same person as in the question below, and he is ranting against the answer to that question. Reported as abuse.
One of these days I'm going to think of a really clever signature.
|
|
|
|