|
Also you can use this :
List<string> list = new List<string>();
using (StreamReader sr = new StreamReader(openFileDialog1.FileName))
{
while (sr.Peek() >= 0)
list.Add(sr.ReadLine());
}
|
|
|
|
|
Or simply:
string[] list = File.ReadAllLines(openFileDialog1.FileName);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
You rarely need to have an entire file in memory all at once; what are you trying to do?
|
|
|
|
|
Hello.
I always wanted to knew that, is possible to create WinForm into the HTML tags.
this means that in our WinForm we use HTML tags to create buttons, menu, text Box, ....
Is it possible ?
Thanks in advance
modified on Saturday, August 9, 2008 7:06 PM
|
|
|
|
|
No. However, if you want to use XAML instead you can do that with WPF.
|
|
|
|
|
You can put a web browser control on your page and point it to local HTML. Not sure why you'd want to tho, HTML is not as rich as winforms
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
hi i wish to use MDI parent kind of thing in my project....
How to carry this out???
csetopper_bhanu
|
|
|
|
|
probably start up with not double posting
|
|
|
|
|
try and understand the requirements or your project. Think : do you really need MDI form??
ask yourself if it is really needed and then if you are stuck, then there are lot of people here to help you.
|
|
|
|
|
I wish to use "MDI parent" kind of thing i my project....
how to carry out this???
My next problem is : what is the syntax of Int32Converter or how to convert a text value to integer value..???
please help me...
csetopper_bhanu
|
|
|
|
|
|
Both of your questions can be answered with looking on MSDN, use it.
MDIParent[^]
Int.TryParse[^]
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Hi All
I drew into PicturBox multi shapes ex: rectangle and circle ..ect
I want when clicking(right click) a user on a rectangle ,the rectangle drew on pictureBox ,occures Contextmenustip control have settings for
rectangle
but if a user click on a circle then occures other Contextmenustrip control have an other settings and properties for circle
Thanks!
ali_dk2008@yahoo.com
or
ali_alsaidi30@yahoo.com
Ali Hadi Alsaidi
|
|
|
|
|
I am not sure if there's a question in here. I am guessing you are saying 'the code I am not showing you is not doing what I want. I am not being clear about what I want, but please fix it'. Sorry, my crystal ball is broken.
Also, a picture box is almost certainly the wrong way to do this, a picture box is only there for people too dumb to write 3 lines of imaging code, but what a picture on their form.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Is there a way to access the explicit interface implementation of a base class from a dervied class without using reflection ?
Because the following lines wont compile, and i dont understand why i shouldn't.
public interface ISomeInterface {
void SomeMethode();
}
public class BaseClass : ISomeInterface {
object SomeInterface.SomeMethode{
...
}
}
public class DerivedClass : BaseClass, ISomeInterface {
object SomeInterface.SomeMethode{
( ( ISomeInterface ) base ).SomeMethode();
}
}
|
|
|
|
|
Why do you declare public class DerivedClass : BaseClass, ISomeInterface at all? Shouldn't public class DerivedClass : BaseClass be enough to ensure that DerivedClass implements ISomeInterface?
|
|
|
|
|
Because i couldn't implement the interface explicit
|
|
|
|
|
MarkPhB wrote: Because i couldn't implement the interface explicit
You need to explain what you mean by this. Implementing an interface explicitly is done for a reason, you might not have wanted to implement the interface explicitly in the first place!
|
|
|
|
|
As ive said above its not entirely clear what you are trying to achieve. However, you can access that explicit interface in the derived class without also implementing the interface.
public interface ISomeInterface{
void SomeMethod();
}
public class BaseClass : ISomeInterface {
void SomeInterface.SomeMethode(){
...
}
}
public class DerivedClass : BaseClass{
void AnotherMethod(){
((ISomeInterface)this).SomeMethod();
}
}
Incidentally if you change BaseClass too the following the commented out line above will work. This is implementing the interface implicitly
public class BaseClass : ISomeInterface {
public void SomeMethode(){
...
}
}
|
|
|
|
|
J4amieC has given you the correct answer above.
It's the difference between explicit and implicit.
If you want to change a value from one type to another in code then if an implicit operator exists you can just set one to equal the other. If not, you have to explicitly cast to the type you require.
The same applies to interfaces. If you implement them explicitly then the cast is required in any classes that derive from the class where the implementation was made.
((ISomeInterface)this).SomeMethode();
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
hi
i have two thread that run two different methods.
in both methods i write a code that read a data from database.
for reading data from database i use sqlDataReader object.
assume two below area code:
first method(for first thread):
cmd.commandText="sql query";
sqldatareader dr=cmd.executereader();
if(dr.Hasrows)
{
dr.Read();
// in here i have a problem when another threads try to execute dr.Read() command of another methods
// because still this datareader object is not close. and the exception error is :
//"invalid try to read data. a datareader must be closed first."
}
dr.Close();
.........
second method(for second thread):
cmd.commandText="second sql query";
sqldatareader dr=cmd.executereader();
if(dr.Hasrows)
{
dr.Read();
// in here i have a problem when another threads try to execute dr.Read() command of another methods
// because still this datareader object is not close. and the exception error is :
//"invalid try to read data. a datareader must be closed first."
}
dr.Close();
-------------
please attention this two methods have completetly different code but in both of them should be read a data from database with sqldatareader. i need a class such as Monitor.Enter(Object) to lock this area codes but the problem is this two area codes are not in one method.
please tell me a solution.
thanks alot.
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
Why don't you let each thread open its own connection?
|
|
|
|
|
thank you frank but i think you didnt understand my problem.
when i open a connection to a database with sqldatareader, i can not open another connection to that database or anyoneelse untill previouse connection will be close.
but in multi threading its maybe happen. what should i to do to avoid to this critical error????
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
mr.mohsen wrote: i can not open another connection to that database or anyoneelse untill previouse connection will be close.
In that case you don't need multiple threads.
If you use multiple threads you need to synchronise access to the
connection so only one thread can use it at a time...may as well
just use one thread.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|