This is my first time creating a C# program so I apologize if this question seems basic. I have 3 list boxes on my design form along with 3 buttons I'd like to load a list of item into each text box when I click the corresponding button for the listbox. can someone instruct me on how to do this.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
all you need to do is create an event handler for each button. You can do it by double-clicking the button on the visual-studio designer. Then you'll see the code window with the following new-created
on this method, implement your item loading method and add them to your ListBox.Items. for example:
Hope it helps and good luck!
These are the steps to load the textfile in the listbox.
Here's a small example on how to do this:
Abbas has given you a sufficient answer, but there are a couple of problems with it, so I thought I would add my own response. The issues:
IDisposable
) need to be closed after you're done with them. You can do this by manually callingDispose()
or by wrapping the creation of the object in ausing
block.I would do something like this:
try this example , remember to include System.IO;
Using System.IO;
Regards.