|
Hello , i am MCSD.NET but i don't know how send Article in to the Code Project help me to How do it
|
|
|
|
|
|
1) can someone help me with code for reloading a form after a button event.
2) also looking for code for running a second form after a button event ie. application contains 2 forms and i'd like to view the second form.
thnx
|
|
|
|
|
1) You can reload the form while calling the Show() method of the form.
Eg:
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
this.Show();<br />
}
2) If you want to show another form from the active form, then you can create the instance of second form and use the Show() method.
Eg:
private void button2_Click(object sender, System.EventArgs e)<br />
{<br />
Form2 frm=new Form2();<br />
frm.Show();<br />
}
Here what you need to notice is, your application will always create new instances of Form2 for each button click.
To avoid this, you can add a Form2 Type declaration and can use this member to create instance of the type Form2 . So now your application show the second form once for every button click.
Eg:
private Form2 frm;<br />
private void button2_Click(object sender, System.EventArgs e)<br />
{<br />
if(frm!=null)<br />
frm.Show();<br />
else<br />
{<br />
frm=new Form2();<br />
frm.Show();<br />
}<br />
}
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I have a webpage with links to xml files. Once a day I have to download these files and store them on a harddisk. I do this by clicking the link and choosing [Save] and so on. I would like to make a component in C# which reacts when the specific URL is called, runs through the html and retreives all files.
Is this possible and how do I register the component to react when the specific URL is called in IE.
|
|
|
|
|
There are many questions before answering this, do the URL's change that point to the XML files? Why does it have to deal specifically with IE? You could request the HTML everyday, parse the returning document for links to XML files and request each XML file.
|
|
|
|
|
Thank you for the quick response.
I will try and explain the problem a little better
The links are at a remote site where I use a chipcard validation to enter. This validation is only valid for this session and the site can only be accesssed by IE and I have no control over this site. So what I am trying to do is making a component which simulate me clicking at the links (up to 800 files) and choosing save when I enter this page.
|
|
|
|
|
You could still perform the individual requests once you were logged in. Also, you could make it appear as if you are coming from IE if the site you are logging into is checking the headers that were posted. Check out the HttpWebRequest[^] class to see if that gets you started.
|
|
|
|
|
I created a new custom control, based on the ComboBox standard control, by inheriting the control. I then put it into a library and added the new control/tool to the toolbox.
After adding the control to a program in several places, it seemed to work as desired and the compiler had no problems with it. However, about 1 out of 10 times, when I go display the interface layout in the visual designer, Visual Studio strips out ALL initialization code for all of the custom controls. It is becoming a major headache having to go and compare the version with the last checked into sourcesafe and try to reconstruct the control initialization code.
Is there any way to get Visual Studio to STOP STRIPPING OUT ALL INITIALIZATION CODE ON CUSTOM CONTROLS????!!!!!!
I am NOT doing anything strange with the control (i.e. adding special code in the InitControls() or anywhere else that Visual Studio has set aside as dynamically generated by a designer refresh). It just insists on stripping out the code IT added when I added the control!!!!
I am having to re-add this init code about 3 or 4 times a week and it is getting EXTREMELY AGGRAVATING!!!!!!!
|
|
|
|
|
|
Thanks for the help. Much of that can help. However, my problem is actually a bit more severe. The following has been true every time I got hit by it...
1. it never happens when starting VS or opening a project. In fact, I will have recompiled successfully/cleanly many times over several hours and it runs fine. I look at the designer window and all looks fine.
2. simply switch between code view to designer and all is ok.
3. make a change on designer view, then switch from designer view to code view and [on occasion] there is a massive pause, then it won't compile. Go back to designer [no pause] and the custom controls are gone. It has always happened when I switch from design view to code view.
4. it has occasionally happened DURING saving changes. After making changes to the designer, I would quick scan around the form to make sure all is ok, then click save. There is a massive pause while designer scans, then the custom controls vanish and it saves the updated file without the custom controls.
5. it has ALWAYS ONLY happened on those custom controls. It has NEVER happened with other controls.
|
|
|
|
|
I'm pretty sure this is "The Woe" described in the article. I know what you're experiencing because when I was using VS 2k3 I experienced it first hand, and only when dealing with custom controls.
The trick, as I remember, was that, before opening ANY designer, rebuild your custom control and make sure everything is saved. If the designer wipes out all your controls, just exit the designer without saving. You're safe, you code is preserved.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lies of Our Fathers: A Must-Know About Lent
Judah Himango
|
|
|
|
|
Oh yeah. Don't get me wrong! I believe it to be the same as well. I am only saying that I believe I have encountered many more causes of the problem, and since I have not been hit by any of the causes indicated in the article, that most of the tips in the article probably won't be of help. I have implemented the following process to see if it helps in my case...
1. place the code for all custom controls in separate library projects. Then add the required control projects as sub projects to the main project that needs the control. Make the main project compile dependant on its compile. Then when I open the main project, compile it before starting any work. In fact, I have gotten in the habit of compiling several times to make sure everything actually gets compiled and refreshed properly.
2. create new custom controls, in the project, that inherits each specific instance of each customized custom control and copy the parent's initialization code into it. For example, if 'a' is a custom control, then create a new object 'b' based on 'a', and create an 'Init()' method in 'b', called from all constructors of 'b'. Then, copy the initialization code of 'a' to the 'Init()' method of 'b'. Then, in the main form load method after the InitializeComponent(), check to see if the auto generated reference to 'a' is null. If so, then declare an instance of 'b' and assign it to the reference. At some point, I should then go back and remove any stray left-over auto-gen code referring to 'a', and then re-add 'a' from the toolbox and then replace the initialization code of 'a' with that in 'b'. This will allow me to start visually editing it again... at least for a while. The down side to this is that if I make visual changes to 'a', I will have to remember to update the init code in 'b' with the changes. This is cumbersome, but considerably less so than having to completely re-add all missing controls from scratch!
3. whenever making a change to the visual layout, switch to the code view before saving. If I make changes to the code, switch to the design window before saving. This way, if the problem hits, it will hit BEFORE the save rather than during the save. It will take some time to make this habit, but it should ensure that the problem does not strike during the save or compile, but rather during the window swap. If controls disappear after swaping, simply close the window(s), choose not to save, and then re-open them. Is there a way to turn off auto save? To make this step reliable, I will have to make sure I know when the save is executed. Also, is there a way to have it create a backup of the current source before saving? I have not been able to find these anywhere, but being able to configure these (if possible) would help tremendously.
|
|
|
|
|
When using the KeyDown event of the form, every key works fine except for the arrow keys (they are inconsistent at best).
The KeyUp event works great, so I am moving some code I wanted to put into the KeyDown event there.
I have tried the same code on several computers, with the same results.
Any ideas???
Thanks
|
|
|
|
|
hi all
hey can anyone tell me how i can add item in the dropdown menu which opens when a right click occur at design time on a control on a windows form ...i just want to able to open property page for that control ..by clicking on the item in menu .......
waiting for relpy any one .......
asayyam
|
|
|
|
|
When u Adding DropDown menu to your Forum , Add that in the Below of your form when you Click On it you can adding Item and Cahnge that Propaerty
|
|
|
|
|
I am about ready to stab myself with a screwdriver i am so frustrated with this....
I have been playing around with WMI for a day now, and have had great luck retrieving information using it. However, I noticed that the "Win32_NetworkAdapterConfiguration" class has a method for releasing and renewing IP addresses. Now, i know this is somehting i can do from a command line easily enough, but i am trying to build an app that will let people that are more or less hopeless when it comes to command line programs perform this very simple procedure. i have been using this so far, but keep getting errors:
<br />
ManagementObject mo = new ManagementObject("Win32_ComputerSystem.Name='" + inf.Machine() + "'", opt);<br />
<br />
<br />
object[] ar = {"ReleaseDHCPLeaseAll"};<br />
mo.InvokeMethod("ReleaseDHCPLeaseAll",ar);
inf.Machine() is a string method i am using to get the machine name.
______________________
Yes, I am the highly suggestable type.
|
|
|
|
|
You never said what the error message was, nor on what line it occurs!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Im writing a windows form in c# to produce little background gradients of various colours for another program. I have tried hundreds of ways to prouce these images, using greyscale templates, sigmaBell gradients, blends however i cant produce what i need.. i can come close, but not close enough..
Does anyone have any tips or knowledge which may help?
The images look like this
Thanks,
|
|
|
|
|
Put a panel on a form named panel1. Use this method for the panel's paint event.
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
using(LinearGradientBrush lgb = new LinearGradientBrush(e.ClipRectangle, Color.White, Color.Silver, LinearGradientMode.Vertical)){
lgb.SetSigmaBellShape(0.5F, 0.7F);
e.Graphics.FillRectangle(lgb, e.ClipRectangle);
}
}
|
|
|
|
|
WOW... you really know you GDI+, that was exactly what i was looking for. Ive tried the SigmaBellShape before but i think my floats really messed it up.. What does the using keyword do? ive never seen it used this way before, only at the start of the class to 'include' various assemeblies.
|
|
|
|
|
The using statement, in theory, is like a try/finally block all wrapped up. Any object you declare within the using statement will be disposed as soon at it is out of scope (i.e. execution exits the using statement). You can also stack multiple using statements in order to dispose multiple objects. It's less code than a try/finally and is more elegant in my opinion. If you want more details look up the keyword on MSDN.
|
|
|
|
|
|
itis easy this way but if u want more efficient UI try using the PathGradientBrush at System.Drawing.Drawing2D namespace it is really cool and u can do somethings which will look like a 3-D shape it is really cool
ByMindOnlyYouCanDoIt
|
|
|
|
|
Thanks guys,
A lot of good info there.. ive decided im going to buy a book on GDI+ as it looks very interesting..
Another question,
im having a lot of trouble in c# trying to copy a folder to a new locaton along with all its files and subdirectories. I can move it no problem but not copy it..
Any hints or guidance?
(I like to work the whole solutions out myself, using just hints if needs be)
|
|
|
|
|