|
Thanks for your help!
It works now!!
|
|
|
|
|
im wanting to click on a item in a listbox and load the txt file into a richtextbox from the folder my main program resides in
can anyone show me how to do this in c#?
modified on Saturday, July 18, 2009 3:01 PM
|
|
|
|
|
What hzve you done so far? Which part of Pete's earlier and fine reply are you having trouble with?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItem == (object)"New DVD")
{
TextBox1. <---- i want to load a text file here from this programs Data folder
modified on Saturday, July 18, 2009 3:19 PM
|
|
|
|
|
deadcell_6 wrote: private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
that is OK
deadcell_6 wrote: if (listBox1.SelectedItem == (object)"New DVD")
that is terrible. Why would you cast to an object?
why would you include a literal string?
I guess your ListBox is showing filenames? if so, get the filename from the selected item.
Could be as easy as
if (listBox1.SelectedIndex>=0) {
string filename=listBox1.Items[listBox1.SelectedIndex];
string s=File.ReadAllText(filename);
myTextBox.Text=s;
}
It probably could use some error handling and some refinement, but that is how it goes.
If all of this is new to you, I strongly recommend you this advice[^]. And do consider reading some CodeProject articles as well!
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thank you
now say i have 10 text files and my code is
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItem == (object)"DVD 1")
{
TextBox1 <--- and i want to display dvd 1.txt
}
else if (listBox1.SelectedItem == (object)"DVD 2")
TextBox1 <---- and i want to display dvd 2.txt
else if (listBox1.SelectedItem == (object)"DVD 3")
TextBox1
else if (listBox1.SelectedItem == (object)"DVD 4")
TextBox1
......
sry im very new
this is what i have now and i think it would be easier to update the txt files as i get more dvds
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItem == (object)"DVD 1")
{
TextBox1.Text = "horror" +Environment.NewLine + "actors:";
}
|
|
|
|
|
deadcell_6 wrote: private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItem == (object)"DVD 1")
{
TextBox1 <--- and i want to display dvd 1.txt
}
else if (listBox1.SelectedItem == (object)"DVD 2")
TextBox1 <---- and i want to display dvd 2.txt
else if (listBox1.SelectedItem == (object)"DVD 3")
...
Eeek!!
Seriously, you need to learn some more of the basics of how to organise and manage data first.
How do you think an application that handles hundreds , or thousands, of pieces of information works? It certainly isn't by having a seaprate "if..." for each one.
Find out about structures, arrays, and file handling (then eventually maybe databases) and think about what information you have and how you want to organise it.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
I develop the application using C#.net in windows xp (english version)
when I run the application the display (image) still good
but when I deploy to another computer which using windows xp (chinese version)
the display (image) become not good
does anyone knows why it happen and how to solve it?
regards,
andy
|
|
|
|
|
eyeshield21 wrote: the display (image) become not good
sure, that must be because your code is not good.
read my sig!
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
can we make printable grid of simple dot net grid, and can we print our form objects with grid? I am trying to create my own report builder for C# forms application
|
|
|
|
|
Does this[^] article help?
/ravi
|
|
|
|
|
Hello friends,
I waana create a set for my window based apllication.I should include some com components like crystal report,ms word-2005.Can u explain me in detail.Thank u.
Cheers,
MAHESH
|
|
|
|
|
|
Thank u for your help.It's really Useful for me.
|
|
|
|
|
Nice to know its help you.
|
|
|
|
|
i want to have a listbox with a bunch of dvds i own, and when i click a dvd i want it to display info about the movie in a richtextbox in C#.net
|
|
|
|
|
deadcell_6 wrote: i want to have a listbox with a bunch of dvds i own, and when i click a dvd i want it to display info about the movie in a richtextbox in C#.net
So retrieve your data from a database, bind it to the listbox and react to the selection changed index.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I have an expandable property, TextLength, with six properties.
TextLength.All = 0
TextLength.ACCAComment = 60
TextLength.AxisDescription = 60
TextLength.Footer = 60
TextLength.GraphicsComment = 60
TextLength.Title = 60
VB.NET 2.0 displays the properties sorted as:
TextLength.ACCAComment = 60
TextLength.All = 0
TextLength.AxisDescription = 60
TextLength.Footer = 60
TextLength.GraphicsComment = 60
TextLength.Title = 60
How can I set the order as:
TextLength.All = 0
TextLength.ACCAComment = 60
TextLength.AxisDescription = 60
TextLength.Footer = 60
TextLength.GraphicsComment = 60
TextLength.Title = 60
In VB.Net 3.5, we can use PropertyOrder(number)
Thanks
|
|
|
|
|
Hi,
As the feature is new in 3.5 it is not available in 2.0
the only thing related is PropertySort, but that won't solve your specific wish.
Switch to 3.5 or get over it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I m working on Accounting Project and i m using DataGridview to display General and Ledger Data(Reports) but using DataGridview which is not displaying Data in Proper Layout and Format(Required by General) but show data in simple tabular form i want to show output with the exact formatting of General so how can i do If some example then plz share
|
|
|
|
|
No one Replied me yet
|
|
|
|
|
I have an application in production that has intermittent errors. I would like to add an error tracking feature so that, when an error gets channeled through the global handling routines, an entry gets written to the Event Log. I would like for this entry to use an event source unique to the application, to better track the errors.
So following Microsoft's own documentation, I tried this:
If Not EventLog.SourceExists("MyApp") Then
EventLog.CreateEventSource("MyApp", "Application")
End If
MyLog.Source = "MyApp"
MyLog.WriteEntry(DetailedMessage)
Unfortunately, EventLog.SourceExists throws an exception: the Framework attempts to check ALL of the logs, not just "Application", and Vista's psychotic paranoia does not allow the Framework to check the System log. So I tried always creating the source and ignoring the "source already exists" exception, like this:
Try
EventLog.CreateEventSource("MyApp", "Application")
Catch ex As Exception
End Try
MyLog.Source = "MyApp"
MyLog.WriteEntry(TextBox1.Text.Trim)
That throws the same exception about the System log, this time on EventLog.CreateEventSource . Attempting to write the entry therefore causes a "source does not exist" exception.
The solutions I have been able to find involve creating the event source manually, by writing the key to the registry. The key gets put in HKEY_LOCAL_MACHINE/System. Vista's "virtualization" has a firm lock on that node and redirects all programatic reads and writes to an isolated, user specific zone. This apparently rules out having the application create the source, as three different users will create three different logs, none of which will be visible to me when I log in as an administrator. And because this app runs on about 40 different machines, it is not feasable to go around to every one and configure the registry manually.
At this point, I see two options:
1. Roll my own event log. Write the errors out to an XML file and write a simple viewer to present the information.
2. Roll every workstation in the office back to XP because I am fed up with Vista.
Please, anyone, is it possible to use the event log under Vista? If so, HOW?
|
|
|
|
|
Just like writing to the HKLM section of the registry, creating an
event source requires elevated privileges. And also just like writing to
HKLM in the registry, apps that runs without elevation need to do these operations
at install time (which is why many installers give you a UAC prompt).
From the EventLog class docs:
"If you write to an event log, you must specify or create an event Source.
You must have administrative rights on the computer to create a new event source."
TechBearSeattle wrote: Please, anyone, is it possible to use the event log under Vista? If so, HOW?
Yes. Provide some way to create the event source. Once the source is
registered, no elevation will be required for the app to write to the
event log.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I want to send email everyday using webServices. Can anyone give a code to do this?
Thanks and Regards.
|
|
|
|