|
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)
|
|
|
|
|
My app was never designed to support threading - The GUI has a VB6 front end but I have rewritten it in VB.NET with a C# backend - don't ask
Some of the operations in the C# back end can take a long time are thus good candidates for running on a worker thread - these operations communicate back to the GUI using events - status information, adding rows to a datagrid, progress bar etc.
As I am new to threads in .NET can I still use the events from the function running on the worker thread but just change the event sinks so they use BeginInvoke to update the GUI controls?
The class which contains the long running operations has some database code in it - can I call that code from the long running operation on the new thread just as I would if it wasn't running on the thread? I don't believe I have any synchronisation issues as the database is always read only - the only reason I want the long running operation to run on a separate thread is so the GUI remains responsive, I dont actually intend to let the user do anything with the GUI other than maybe cancel the long running operation.
TIA
|
|
|
|
|
Sorry, posted it twice - the first attempt too 20 minutes then went blank - when I looked it wasn't there so I reposted it - naturally the first one decided to appear in the meantime
Rugby League: The Greatest Game Of All.
|
|
|
|
|
|
Thanks, I have read those articles and also in his book on Windows Forms programming where the articles are repeated. They don't really address my events question though.
|
|
|
|
|
Yes, you can still use evens. The article details exactly how to do it in terms of your GUI. First, subscribe to the events or use a delegate which points to your GUI's method. Either way will work fine. Your thread will call it's delegate or raise its event, and the UI thread will receive the notification.
In your gui you'll need code similar to this to handle the event:
private delegate void uiThreadDelegate(object sender, EventArgs e);
protected void MyEventHandler(object sender, EventArgs e)
{
if(this.InvokeRequired)
{
uiThreadDelegate ui = new ThreadDelegate(MyEventHandler);
this.BeginInvoke(ui, new object[]{sender, e});
}else{
... your code
}
}
|
|
|
|
|
My app was never designed to support threading - The GUI has a VB6 front end but I have rewritten it in VB.NET with a C# backend - don't ask
Some of the operations in the C# back end can take a long time are thus good candidates for running on a worker thread - these operations communicate back to the GUI using events - status information, adding rows to a datagrid, progress bar etc.
As I am new to threads in .NET can I still use the events from the function running on the worker thread but just change the event sinks so they use BeginInvoke to update the GUI controls?
The class which contains the long running operations has some database code in it - can I call that code from the long running operation on the new thread just as I would if it wasn't running on the thread? I don't believe I have any synchronisation issues as the database is always read only - the only reason I want the long running operation to run on a separate thread is so the GUI remains responsive, I dont actually intend to let the user do anything with the GUI other than maybe cancel the long running operation.
TIA
|
|
|
|
|
There's a very good basic article here[^] that will probably cover most of the bases for you. It's a time saver if you don't want to reinvent the wheel with respect to UI <-> worker thread interaction.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi,
I'm completely new to this theme and I have the following problem: I want to reload the page via code like a serverside button does (PostBack event should be triggered), when beeing clicked. So, how can i achieve that?
Till now I didn't find any proper function looking in the System.Web.UI.Page class and using the meta tag <meta http-equiv="refresh" content="10"> reloads the site but triggers no PostBack event.
Thanks.
BTW: I'm using webforms and c#
|
|
|
|
|
hi,
you can cause postback with JS:
var form = document.getElementById(formID)
form.submit;
This will have same effect like user hitting submit button.
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
How do you plan to trigger this reload? Is it the result of a button press or ??
If it's the result of a button press (running at the server), then chances are the page is already posting back (unless you've changed the default behavior of the button).
If you're trying to do it from the client side, then you're most likely going to have to use script, as the previous post suggests, unless you're using one of the Html controls that includes a ServerClick event.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
BTW, this question really belongs in the ASP.Net forum, not this one.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|