|
My question is simple -> can I get full name of assembly in which resides my function that is currently running. To clarify:
<br />
static string ReturnName()<br />
{<br />
return "This function runs in assembly named:"+ Class.Property.ToWhich.U.Need.To.Point.Me<br />
}<br />
Tnx
|
|
|
|
|
How about Reflection.MethodInfo.GetCurrentMethod().GetType().Assembly.GetName().Name ?
Or something like that.
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
But you were close
Tnx a lot!
|
|
|
|
|
I'm drawing a few shapes on an img field on a windows form by overriding OnPaint, and using a double buffer as many people have detailed here. However, my shapes disappear after they are drawn. If I put a Refresh() at the end of my OnPaint override, it works (but obviously bogs down)If I set a timer it flickers at the rate of the timer.
What am I doing wrong?
|
|
|
|
|
Uf, that happend a lot when I first used drawing. What I learned is that drawing directly in OnPaint event isn't good solution in most cases, better draw it in Form_Load for example.
What you must know is that in this case you need refresh you drawing in Form's Activated event... because if you hide ur Form (which happends a lot when in debug mode) and than show it again your precious work will be gone...
If you follow my suggestion and drop function calling in Page_Load then you'll have code like this:
<br />
Form_Load()<br />
{<br />
DrawStuff();<br />
}<br />
<br />
Form_Activated()<br />
{<br />
DrawStuff();<br />
}<br />
In case you stick with OnPaint() I guess simple this.Invalidate(true); in Form_Activated should do the trick.
I guess someone will eventualy give you right answer but if you get stuck, drop a code - that will help us to help you.
cheers
|
|
|
|
|
Thank you for the response
I am still a bit confused, however. One of the shapes I'm drawing I'd like to follow the mouse as it moves over the img box - So I would have to refresh() each time the mousemove event triggers, correct?
If I put the refresh() in the mousemove event it seems to work fine as long as the mouse is moving, but as soon as the mouse stops, the shape disappears. This is really frustrating!
Thank you for any help - mutty
|
|
|
|
|
This is working for me... even if Refresh in MouseHover is commented... but maybe you should try uncommenting it.
<br />
private void pictureBox1_MouseHover(object sender, System.EventArgs e)<br />
{ <br />
}<br />
<br />
private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{ <br />
Refresh();<br />
}<br />
<br />
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
using (Graphics g = this.CreateGraphics())<br />
{<br />
PaintEventArgs pa = new PaintEventArgs(g, this.ClientRectangle);<br />
g.SmoothingMode = SmoothingMode.AntiAlias;<br />
<br />
pa.Graphics.DrawLine(new Pen(Color.FromArgb(255, 0, 0, 0)), <br />
new PointF(MousePosition.X-10, MousePosition.Y+10), <br />
new PointF(MousePosition.X-20, MousePosition.Y+20));<br />
} <br />
}<br />
In any case, if you can't get it to work, drop me .cs on pele@zig-zag.net and I'll look into it.
Cheers
|
|
|
|
|
Hi!
I was just wondering how I could delete 1 row from the results I get in my datagrid. Everytime data shows in my datagrid, an edit/delete button appears for every row i fetch. Now what I want to happen is that if I fire my delete button only the row aligned to it gets removed. Now my problem is that my page hangs when i click the delete button. I've debugged it and it stops right before my curly bracket
<br />
if (Page.Request.QueryString["Mode"] == "Delete")<br />
{<br />
objCol.DeleteColors(Page.Request.QueryString["key"],"");<br />
Response.Redirect ("SysColors.aspx");<br />
}
<br />
public bool DeleteColors(string strObject,string strColors)<br />
{<br />
try<br />
{<br />
strSQL = " DELETE FROM sys_colors";<br />
strSQL += " WHERE object = '" + strObject+ "' ";<br />
strSQL += " AND c_code = '" + strColors + "' ";<br />
<br />
OdbcCommand cmdDelete = new OdbcCommand();<br />
cmdDelete.CommandText = strSQL;<br />
cmdDelete.Connection = cnnDS;<br />
cmdDelete.ExecuteNonQuery(); <br />
<br />
return true;<br />
}<br />
catch (Exception e)<br />
{<br />
throw e;<br />
}
I hope I didnt forget anything this time...Thanx for all your help! Much appreciated! My apologies for the inconveniences
Kampai!!!
|
|
|
|
|
Firstly - what curly bracket ?
Second - is c_code always empty ? If not, this will never do anything
Third - why is your table called sys_colors ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Third - u must admit that it is fancy name
And what about Connection.Open()?
|
|
|
|
|
1. The "}" below my if statement
2. c_code always has data in it...but can you please explain to me the concept on why it shouldnt always be empty? Thanx!
3. sys_colors=systems colors. It's a table full of colors for each part of the company website
3.a. I've the Connection.Open(); part above my form.
Kampai!!!
|
|
|
|
|
if (Page.Request.QueryString["Mode"] == "Delete")
{
objCol.DeleteColors(Page.Request.QueryString["key"],""); // 2 - you always pass an empty string to compare with c_code, so it will never do anything anyhow
Response.Redirect ("SysColors.aspx");
}// 1. If it hangs here, then there's nothing else for the debugger to show you, it's gone off to another form. Put a break point in the other form to see if it gets there. I assume you've stepped through to see the rest is executed ?
//objCol
public bool DeleteColors(string strObject,string strColors)
{
try
{
strSQL = " DELETE FROM sys_colors";
strSQL += " WHERE object = '" + strObject+ "' ";
strSQL += " AND c_code = '" + strColors + "' ";
OdbcCommand cmdDelete = new OdbcCommand();
cmdDelete.CommandText = strSQL;
cmdDelete.Connection = cnnDS;
cmdDelete.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
throw e;
}
3 - sys_ is the prefix for system tables, so why are you using it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
oh...darn. About the sys_ its a pre made table by the other programers God knows who. So the 2nd parameter is what keeps it from doing anything coz its set as "".
Yeah everything else is executed except for this delete button and a slight problem in my save button. It's suppose to save the color on only one row however it saves a color i choose for every row. I guess i should explain that a color is asigned for every part of the website. For example the background color is blue then the forecolor is red. What happens is when i choose for example again green to be set as the background color, green is also set for the rest of the parts. Well thats a different problem altogether right...?
Kampai!!!
|
|
|
|
|
tatchung wrote:
About the sys_ its a pre made table by the other programers God knows who.
There's no naming conventions on this app ?
tatchung wrote:
the 2nd parameter is what keeps it from doing anything coz its set as "".
OK, that's by design for now ?
tatchung wrote:
Well thats a different problem altogether right...?
Yes, sounds like the SQL is flawed there.
So did you try a break point in the other page ? Does the SQL execute ? I guess it's hard to say, seeing as it does nothing right now.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yeah it the SQL executes then when it goes back to my UI then it hangs at the bracket shown earlier. I've tried removing the Response.Redirect(SysColors.aspx); line then the delete button fires but now it doesn't do anything at all.
Im really sori for all the trouble. Im still learning c#. Thanks for your undying patience
Kampai!!!
|
|
|
|
|
tatchung wrote:
Yeah it the SQL executes then when it goes back to my UI then it hangs at the bracket shown earlier. I've tried removing the Response.Redirect(SysColors.aspx); line then the delete button fires but now it doesn't do anything at all.
Like I said, you need to put break points in the new page, to see if the redirect ever gets there. And it doesn't do anything at all for the reason I said before, you need to pass in something other than an empty string for that second value.
tatchung wrote:
Im really sori for all the trouble. Im still learning c#.
It's no trouble, that's what these boards are for. If I decide it's too much trouble, I'm free to not respond, and someone else will.
I've been developing for about 6 years, and nowadays I have a goodjob, and a number of contract jobs I do on the side, giving me an above average income, doing things I love. Everything that I achieve now, is as a direct result of me asking far more stupid questions than these on these same boards 6 years ago, and other people answering them. ( I'm self taught ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I did actualy and it does arrive at the other form. Yeah i figured it has something to do with the 2nd value being set to "".
Thanx Chris! Looks like I'l be following ur path since im self-studying as well. I've no idea whatsoever on programming and being an intern in a company gave me the opportunity to initialize my technical skills...interesting...how did I get to c#? Oh well! Thanks again! Till my next stupid post!
Kampai!!!
|
|
|
|
|
tatchung wrote:
Yeah i figured it has something to do with the 2nd value being set to "".
That should really just cause the SQL to do nothing, I'd have thought.
tatchung wrote:
I've no idea whatsoever on programming and being an intern in a company gave me the opportunity to initialize my technical skills
What's an intern, is it like an entry level position ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
intern = ojt = on the job trainee.
I'm a management student but the only opening i got for my ojt was this programmer position. So as you can see...it really is hard for me to study under certain conditions given by the company and intense time pressure pressed by some of our clients. But don't get me wrong...I enjoy working my mind in programming and i enjoy programming per se. It sorts of develop self awareness and of course...my chess skills!
Kampai!!!
|
|
|
|
|
OK - I see. I've heard the term often, but wasn't sure what it meant. Management->programming, that's quite a leap. Good luck with it all !!!
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanx! I'd make good on this!
Congratulations on your acheivements Chris and Gud luck to you in the future! Till my next post!
Kampai!!!
|
|
|
|
|
Hey Chris! I was wonderin if you could spare a minute of ur time to help me out with this simple problem.
Regarding the delete button we've discussed before...yeah i finally made it work but there's just one slight problem...I've 2 entries in my dropdown list..."CompanyA" and "CompanyB" where "CompanyA" populates the top index of the dropdown list. Now everything works smoothly even the delete button but when I choose "CompanyB" and delete a data from its queries it deletes a data from with the same object from "CompanyA". I've been bugging the whole day about this problem. Here's my new code in the delete button
if (Page.Request.QueryString["Mode"] == "Delete")<br />
{<br />
objCol.DeleteColors(Page.Request.QueryString["key"],ddl.SelectedItem.Text);<br />
}
I've tried debugging and used "? ddl.SelectedItem.Text" (i'm not sure what that is called) which still retuned "CompanyA" even though I chose "CompanyB".
Thanx in advance!
I didnt create a new thread...figured u'd reply faster here. Hehe...sori for the inconvinience.
Kampai!!!
|
|
|
|
|
Looks to me like you databind with your data source on postback, which will reset the item selected.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I get the name of the control in string format in an event: "control1"
And I want to modify its properties (for ex.: control1.BackColor = Color.White;
How can I convert or point this string to the existing instance of the control??
regards
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Reflection.
Christian Graus - Microsoft MVP - C++
|
|
|
|