|
Debug.Trace isn't even close to being the same thing. What you really want is Debug.Assert() in the System.Diagnostics namespace.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Oops. you caught me. That's what I meant to type.
|
|
|
|
|
Hi,
sorry for my bud English.
I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?
Alex
|
|
|
|
|
I think this[^] should help you.
|
|
|
|
|
thanks ... I try this ..
Alex
|
|
|
|
|
It works great!! Thanks a lot!!
)))))
Alex
|
|
|
|
|
You're welcome.
|
|
|
|
|
Your problem is probably caused by not doing all of your drawing in the Panel's Paint event. Do NOT create your own graphics object. Use the one that Windows hands you in the event args of the Paint event.
|
|
|
|
|
thanks Dave, I try to not create a graphics obj ...
Alex
|
|
|
|
|
Drawing a grid on a panel? I just did that a little while ago. Here's a sample that makes a 20-px grid.
private Pen pen = new Pen(Color.FromArgb(60, 60, 60), 1);
private void something_Paint(object sender, PaintEventArgs e)
{
for (int x = 20; x < Width; x += 20) e.Graphics.DrawLine(pen, x, 0, x, Height);
for (int y = 20; y < Height; y += 20) e.Graphics.DrawLine(pen, 0, y, Width, y);
}
[Edit]: Moved Pen object out of method.
|
|
|
|
|
You forgot to Dispose the Pen. Nothing like an example that leaks GDI resources!
|
|
|
|
|
Or even better, don't re-create it on every Paint in the first place. Moved it out of the method.
|
|
|
|
|
thanks to all ..
Alex
|
|
|
|
|
Hello, My question involve both code and algorithm so I'm hoping I'm in the right place:
I have a win form application with c# and fw4.
I have a panel (name P1) and I'm adding buttons dynamically to him in run time based on a file list I read from a directory (for each file I read I'm creating a button with the file name as text and add him to the panel controls).
I have another panel (P2) with same process from another list.
Now - I want to navigate between the buttons in P1 when I'm pressing the left/right keys and between the the buttons in P2 when I'm pressing the up/down buttons.
I have a lots of ideas to do that (save a list of buttons in each panel and a variable to remember on which button I am, maybe using a hash table ).
I know how to do the programing stuff (creating every thing, getting the key press and so on) I just can't think of a normal algorithm for that. all my ideas seems lame
Hope I'm in the right place and thanks in advance.
|
|
|
|
|
OK. Lets have a generic list of some type (Button to start with) for the first panel, and similar for the second. Then hold an integer index variable into the list. Next, have the form preview your keyboard input, check for an arrow key, and modify the appropriate index variable (make sure to check for boundary values, so you don't exceed the range of the list).
The items in your list could better be instances of a little class, that holds the Button itself, the file name, and whatever else you may want it to hold.
And finally, you could make a custom Panel-derived class that does the above (scanning a folder, creating your objects, showing the buttons, holding the list, etc.), as you basically need the same thing twice.
|
|
|
|
|
Hi Luc,
Thanks for the reply. I think I'll skip the custom panel for now
I thought about list of only names at first and then find the button with Panel.Controls["name"] but now I think maybe to do a list of buttons and then I can click may button only bay index in the list with out the need to find the button in the panel every time.
Thanks for the ideas.
|
|
|
|
|
hi all
i have a web service.a function get 2 parameters and return a string.
public string zakhire(string s,string d)
{
string sql = " insert into FX_Forecast2 (Symbol,DateTime) values( '"+s+"',"+d+")";
OpenDb();
cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
con.Close();
return sql;
}
i want after executing function these 2 parameters with function name be in url,but just function name passes in url,not parameters and their values!!!
can someone say how to pass parameters??
do i should write code else to do this?
thnx
|
|
|
|
|
Firstly I would suggest do not build your query like this:
string sql = " insert into FX_Forecast2 (Symbol,DateTime) values( '"+s+"',"+d+")";
You leave yourself open to SQL Injection Attacks[^] Use a paramterised query[^] instead.
Secondly, you are not checking that d is a date: this is a recipie for disaster or, at least insert failure exceptions, which are costly in terms of performance.
Points 1 & 2 are especially true if the values are coming from outside you application, such as the WebServce you state.
Finaly, if the strings s and d are correct, your SQL will be generated correctly as far as I can tell, so the problem is probably with the code calling this method. Have you checked that values of s and d ?
|
|
|
|
|
Sage Advice and a Good Answer!
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
about point 1: your advise is correct.
about point 2:arrival parameters evaluate in another software that send these to this web service.so they are correct.
this url has shown when execute method:
http:
but i want to pass parameters and values in url after method name.
what's the problem that don't show parameters in url?
|
|
|
|
|
roebuck-code wrote: about point 2:arrival parameters evaluate in another software that send these to this web service.so they are correct.
Not necessarily: their code could be buggy, the web-service client they are using might be poorly formed or of a different version. You need to check the values coming in. You shouldn't trust anything coming into your webservice, even if you provide it.
IIRC, the values from the querystring don't get passed into the asmx method by default, they normally come from the SOAP message. As for getting stuff from the query string you'd have to do something like the following:
string value = Request.QueryString.Get("name").ToString();
|
|
|
|
|
Keith has already pointed out to you why your approach isn't considered to be within the best practices.
My philosophy in any project I'm involved with is that at any level, always assume the consumer of a method/service doesn't know what they are doing. How do you protect yourself.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
roebuck-code wrote: be in url
What URL?
As Keith has pointed out you should never accept unvalidated input to your Sql statements. Use stored procedures or at least a parameterized query.
If you want to return the command text that was executed, though I can't see why you would, then use SqlCommand.CommandText
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: What URL?
after executing this method,open a page that show me this answer:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">insert into FX_Forecast2 (Symbol,DateTime) values( '4',56/8/8)</string>
in page's url has been written method name.
i want after it be parameters and values.
|
|
|
|
|