|
I have no idea. In my quest to get my hands on sample code, I have accumulated so may samples code, ePages etc. This seems to me from a book that have labs and or modules. The one module, Mod08 has three samples, DataFormWizard1, DataReader and XMLData. This is about all I know. And there is no indicatoion in the sample code wher it is coming from.
Thanks
P
|
|
|
|
|
I want to realize the following:
I have created several buttons, each of them has a name related to a function (i.e. the function name is the same to the button name). Now I want to call the corresponding function according to which button you click. Of course, you can not use "switch" or "if" conmmands to realize it. because the buttons as well as the funcitons are not fixed.
for example, I have buttons with name A, B, C,...
there are also the corresponding functions void A();void B(); void C();...
I want to call void A() if you click button with name of "A", I want to call void B() if you click button with name of "B", and so on.
Could you please give me an simple method for that?
thank you very much.
|
|
|
|
|
OK - assuming that your buttons and functions have better names than A, B and C, you could use reflection to handle this. Off the top of my head, I would expect that you could handle this with:
private void ButtonHandler(object sender, EventArgs e)
{
string name = ((Button)sender).Name;
this.GetType().InvokeMember(name, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, this, new object[] { });
} Then all you would need to do is wire up your buttons to this one event handler.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thanks a lot!
I will try it!
|
|
|
|
|
No problem.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
HI,
I'm using FtpWebRequest class to provide ftp communication in my application. All is fine, except it sometimes fails. I've tried everything what I could, it just sometimes fails - throws
System.Net.WebException: The remote server returned an error: (500) Syntax error, command unrecognized.
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
To be more specific - it is download command (WebRequestMethods.Ftp.DownloadFile).
It runs on a speparate thread in background worker, code :
<br />
FileStream clientStream = new FileStream(this.DestinationPath, FileMode.Create);<br />
FtpWebResponse response = (FtpWebResponse)this.Request.GetResponse();<br />
this.GotResponse = (response != null);<br />
<br />
Stream ftpStream = response.GetResponseStream();<br />
<br />
this.ContentLength = response.ContentLength;<br />
<br />
int bufferSize = 2048;<br />
int readCount;<br />
byte[] buffer = new byte[bufferSize];<br />
<br />
readCount = ftpStream.Read(buffer, 0, bufferSize);<br />
<br />
long dataTransfered = 0;<br />
<br />
while (readCount > 0)<br />
{<br />
if (this.Worker != null && this.Worker.CancellationPending)<br />
{<br />
canceled = true;<br />
this.Request.Abort();<br />
break;<br />
}<br />
<br />
this.CheckPause();<br />
<br />
lock (this)<br />
{<br />
this.lastLoadedSize += readCount;<br />
} <br />
<br />
dataTransfered += readCount;<br />
<br />
clientStream.Write(buffer, 0, readCount);<br />
<br />
if (this.ContentLength > 0)<br />
{<br />
int completed = Convert.ToInt32(((float)dataTransfered / (float)this.ContentLength) * 100);<br />
this.ReportProgres(completed);<br />
}<br />
<br />
readCount = ftpStream.Read(buffer, 0, bufferSize);<br />
}<br />
where this.Worker - Worker object that provides thread for running.
I dont know if it is a problem inside WebRequest class or in my code(where ???) .
Thanx for any help!!
|
|
|
|
|
Chances are the server doesn't understand one of the commands being sent. Check out this[^] for more information.
|
|
|
|
|
I can't open the link you posted.
|
|
|
|
|
I had a similar problem when accessing Microsoft's forums site through IE. Try flushing your cache (and delete any microsoft.com cookies) or switching browsers.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I did in diffrent explorer
|
|
|
|
|
I don't thing that server doesn't recognize that command, because it works most of the time. It fails only from time to time, unpredictably.
It's behavior is like races when doing multi threading (of course it is done using separate threads, but the whole operation runs on one thread -> Get Response, Download data (write data to HDD), Close stream).
I'm desperate
|
|
|
|
|
The link that partymonkey posted has a method for gathering some trace information, which may help you debug the issue.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I've created that log, it seems that it might be helpful, thanx.
|
|
|
|
|
how can i make item in combobox invisible? the item is in middle of combo if i remove it. it will effect the whole indexing so i want to make it invisible
|
|
|
|
|
Hi,
I don't think that it's possible to make it invisible.
if u can't rely on indexes, create wrapper for your object, where U can add a int field with index(key, whatever). Then just get the SelectedItem and if it's not null, read that item index. Override ToString() method of your wrapper object, to make combobox display whatever tou want to display.
Stevo
hope that helps
|
|
|
|
|
I have one simple but difficult problem:
I plot some lines in a panel with Graphics in C#, now I want to select one of them to edit it.
I don't know how to select it?
xiachunmin
|
|
|
|
|
Hello,
You have to do it all by yourselve, AFAIK.
I think the fastest way is to handle the MouseDown and MouseUp event of the Panel.
Save the two MousePoints, as this will discripe an rectangle, SelectionRectangle.
Then you have to iterade over all your lines and validate each of the lines.
You could use the IntersectsWith method of the Rectangle class for that.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Not as simple as you might think. You have to specify your problem a bit more clearly.
What exactly is it that you want to select? The lines that you have drawn doesn't exist as lines any more, they are just differently coloured pixels on the screen, so what you have to select is something that you use to keep track of the lines. How do you keep track of the lines?
What method do you want to use for selection? Detecting mouse clicks?
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello, Guffa,
Thanks a lot.
You are right by saying “The lines that you have drawn doesn't exist as lines any more, they are just differently coloured pixels on the screen”.
That is the reason I can not select it by mouse clicks. I want to find some solution to keep track the lines, just like in MS word, after you plot one line, then you want to select it and edit.
Could you please tell me the best method to realize it?
Thanks a lot again.
Chunmin
|
|
|
|
|
The normal way to do this is to represent the line as an object in it's own right. Then the line could detect the MouseClick event and respond to it however you want.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete is right, you have to represent the lines as objects in your code somehow.
If you don't already do this, then you aren't drawing the lines correctly. You need to keep track of the lines in order to properly draw them in the Paint event of the control. If you just draw the lines outside the Paint event, they are just drawn on the screen where the control happens to be, and the control is not at all aware of the lines. Whenever the controls is redrawn for any reason, the lines will disappear.
---
single minded; short sighted; long gone;
|
|
|
|
|
Your best bet is to derive a class from the panel class, so you can centralise and reuse the code. The panel would keep an array of Line objects ( you would defne this class, it would have two points ), and then your code would work out which line is selected ( this is probably the hardest part, working out if someone has clicked on an arbitrary line. It's well documented online tho, and not THAT hard ).
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
do you prefer to use Dataset or direct SqlCommand to update your DB ??
for .net 2003
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
I am using a direct SQL query to update my database.
|
|
|
|
|
do you suffer from marinating string ??
and what are the advantages of direct SQL queries
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|