|
try tr.ReadToEnd method please.
I think the first line is a blank string in your file.
|
|
|
|
|
When I saw your suggestion, I got excited. But, alas, there was no happy ending.
To put it in context, I'm including the openfiledialog as well.
private void openToolStripButton_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
this.openFileDialog1.InitialDirectory = @"c:\";
}
}
private void ReadFromFile(string filename)
{
TextReader tr = new System.IO.StreamReader(this.openFileDialog1.FileName);
this.textBox1.Text = tr.ReadToEnd();
tr.Close();
}
If you have any more suggestions, I'm all ears.
|
|
|
|
|
Soooo....where do you call ReadFromFile???
|
|
|
|
|
Oops, missed that. Thanks for the catch. Added it...now it just locks up.
By the way, did I say or do something wrong???
|
|
|
|
|
I sugguest you check the value of the openFileDialog1.FileName.Make sure that's a file's real path.
If this way cannot help you try these codes:
//First ,create a txt file at C:\
// create reader & open file
TextReader tr = new StreamReader(@"c:\1.txt");
// read a line of text
this.textBox1.Text = tr.ReadLine();
// close the stream
tr.Close();
Good luck.
|
|
|
|
|
If you're using .NET 2.0, System.IO.File.ReadAllText(openfileDialog1.FileName) should do it ( or something similar )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you so much. I love you , man...
|
|
|
|
|
I have a dataview..... When it retrieves data from the database there is a column in my data base that stores 1's and 2's. 1's mean 'Yes' and 2's mean 'No'. This column (St_Assess_Ev_Checked) has been declared as an Integer.
How do you iterate through a dataview, if it see's 1 it prints yes to my datagrid and if it see's 2 it prints no. This is my code so far.... hope I'm at least close.
DataSet sqlDS = new DataSet();
SqlDataAdapter sqlDA = new SqlDataAdapter(stReport, sqlConnection);
sqlDA.Fill(sqlDS, "progReport");
dv = sqlDS.Tables["progReport"].DefaultView;
IEnumerator iterator = dv.GetEnumerator();
foreach(DataRowView drv2 in dv)
{
for (int x = 0; x < dv.Count; x++)
{
if(dv[0]["St_Assess_Ev_Checked"].ToString() == "1")
{
dv.AllowEdit = true;
dv[0].BeginEdit();
dv[0]["St_Assess_Ev_Checked"] = "Yes";
dv[0].EndEdit();
}
else
{
Response.Write(dv[x].ToString());
}
}
}
You could of guessed the error.... Cannot convert types expected Int32!
Thanks in advance, appeciate it!
|
|
|
|
|
Do it in your datagrid ItemDataBound event. This should help you.
SG
|
|
|
|
|
Hi,
My English is not native, sorry.
I have MDI form and Child form.
I added "Form_Closing" event to the MDI code file. the following is the code:
private void frmMainMdi_FormClosing(object sender, FormClosingEventArgs e)
{
// Hold the MessageBox button pressed
DialogResult diaResult;
// Show Message to the User
diaResult = MessageBox.Show("Are you sure you want to cancel the setup?",
"Exit Setup",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2);
// Checking which button as been pressed
if (diaResult == DialogResult.No)
{
// CANCEL pressed, set focus to the program
e.Cancel = true;
}
else
{
// YES pressed, exit the program
this.Dispose();
Application.Exit();
}
}
Now, in the child form i have CANCEL button that suppose to teminate the application if the user press YES.
I added to the click event the following code:
private void btnCancel_Click(object sender, EventArgs e)
{
Application.Exit();
}
And now I am having the problem.
I am getting an error when I try to cancel the program and the error points to the cancel button, application.exit();
How can I terminate the program from runnning when pressing the cancel button?
Thanks
VBDC
|
|
|
|
|
Hi,
I tried to reproduce the error that you are referring here, but couldn't reproduce it.
The MDI parent form's closing event is not firing because you are calling Application.Exit() in the Child form, which closes the entire epplication.
May be some other code you have is creating the error.
Blumen
I wish to become a software consultant.
|
|
|
|
|
Hi to All,
My English is not native, sorry.
Ok, I have MDI form and Child form.
in the MDI code file I added "Form_Closing" event.
private void frmMainMdi_FormClosing(object sender, FormClosingEventArgs e)
{
// Hold the MessageBox button pressed
DialogResult diaResult;
// Show Message to the User
diaResult = MessageBox.Show("Are you sure you want to cancel the setup?",
"Exit Setup",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2);
// Checking which button as been pressed
if (diaResult == DialogResult.No)
{
// CANCEL pressed, set focus to the program
e.Cancel = true;
}
else
{
// YES pressed, exit the program
this.Dispose();
Application.Exit();
}
}
Now, In the child form I have CANCEL button that suppose to close the application if the user press "YES".
I added to the cancel button click event:
Applicarion.exit();
and then I am having an error.
How can I close the program from the child form using the Form_Closing event from the MDI form.
Thanks
VBDC
|
|
|
|
|
I have to implement A peer-to-peer text messaging application . the idea is as follows.
Please has anyone designed a similar application ! i would be very greatful if u can help ?
In a client- server paradigm clients never communicate directly with each other. This often leads to the centralisation of user interaction. The peer-to-peer (p2p) model tried to overcome this problem. In a p2p model, users cannot communicate directly with each other. It may be helpful to view a ‘peer process’ as an entity incorporating a client and a server within it.
A peer process typically uses a central server, a peer-directory, to find out about other peer processes in the system. Peer-directory maintains a table whereby the address and port number of a peer is mapped on to a single integer index. Peers identify each other by this index number. We will refer to this index number a peer-id.
The central server or the peer-directory provides a mechanism whereby peers can coordinate their interaction in time and pace. However, the rest of the interaction can then be conducted directly, without the need for the central server. In this way, significant reduction of centralized communication can be achieved and a more distributed pattern of network usage is created. In a peer-to-peer text system the central server maintains a table where information on member is stored. Whenever a new member subscribes into the system, the central server sends the updated table to all members of the group. Peers send text messages directly to each other.
Centre peer. The interaction between peer and peer directory can be organized in such a way that peers are automatically notified whenever a new member enters or exit the peer group.
|
|
|
|
|
This reads like a homework assignment. What bits are you stuck with ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
just the basic idea how to put into design ! files i have to create, and actual implementation
Have you done any kind of application similiar to this one ?
thanks
|
|
|
|
|
This seems like an exam question..
You can use socket communication for this purpose. There are lots of articles in CP related to this.
I wish to become a software consultant.
|
|
|
|
|
http://www.centrumxp.pl/dotNet/831,1,Komunikator_w_C.aspx
- it's in polish but hope it helps
life is study!!!
|
|
|
|
|
is there a way to set up multiple audio cards to play multiple sources separate, and together? for example, i want to set up a whole home audio system using a single computer. i want to use 3 sound cards and be able to play 3 separate audio sources to separate rooms from the single box, and if i want, combine the sound sources to play throughout the house simultaneously. is there a way to do this?
|
|
|
|
|
What does this have to do with C#? And in response to your connections yes I would think this is possible.
|
|
|
|
|
uhhh, i'd like to know how to accomplish it with c# programming? if it's possible?
i'd like to create an app that can take advantage of this, but i don't know the how to do it
-- modified at 20:28 Tuesday 8th May, 2007
|
|
|
|
|
A simple Google search would have resulted in this[^] article.
|
|
|
|
|
This may be lower level than what you're looking for, but you can use the managed version[^] of DirectSound to send waveform data to your soundcards.
|
|
|
|
|
Hi,
Can any one tell me, how to copy the tables from one database to another? and how to create database in MySQL at runtime?.
Gopal.S
|
|
|
|
|
Gopal.S wrote: how to create database in MySQL at runtime
A quick web search brings up this result[^].
|
|
|
|
|
I am coding a "Trace" object. This object will report the "method name" of the method within the class that the code is currently executing. I do not want to have to type in the method name each time the trace object is called. I simply want to determine tha nem of the method call that is currently being excecuted. How Can I accomplish this?
"Moose Man"
|
|
|
|