
Cags
Avatar/Signature-
Posts
699 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Cags
-
Its certainly possible, as its midnight off of the top of my head the only idea I have is extremely crude and I wouldn't recommend it as a final solution. But one way of achieving this would be to loop through the Controls property of the form (i.e. all the controls on the form) check if its type is button and if it's name is equal to buttonName then set its visibilty property to the appropriate value. I'm pretty sure there is a GetObject method that you can pass a type and a name but i'm too tired to look it up now. EDIT:- Obviously this isn't particular dynamic in the manner that marble suggests, but it seemed to fit your requirements.
-
Having such long names would certainly be commonplace whilst referencing objects that are in a namespace not included in the using section of a page (or in order to avoid clashes with the same name in differen't namespaces). For example I'm often writing System.Drawing.Rectangle as its the only place in a class I use something from that namespace. Combine this with a particularly long named namespace or class and you soon get very long names very quickly.
-
Just a cautionary notice, when using a Graphics object you should always remember to call the Dispose method when your done with it.
-
Check out this page... http://blogs.msdn.com/mollman/archive/2004/09/07/226483.aspx
-
I spent ages trying to emulate your problem without success before I finally realised your using the keyup event and I was using the keydown event. Would it be possible for you to use the keydown event as this seems to stop the problem.
-
You could try setting a public boolean when the messagebox is displayed, and set it back after it has been closed. Then in the key event you check if the key is enter and the bool is the right value. I've not checked this, but the theory is sound.
-
Well I'll be the first to admit I don't understand alot of programming concepts but what you've said has really confused me. You seem to be saying that when using the for loop the entire array will be loaded into memory but when using the while loop it won't. Yet I can't see a real conceptual difference. I could understand if the argument was a for each statement as this may very well load the entire array into memory, but I see nothing in a standard for loop that would make the system load the entire array into memory. Using either method you are looping through a series of integers, accessing that index in an array then incrementing the index before repeating the process. This is all repeated untill the required object/ value is found. Maybe somebody else can shine some light on this and clarify what actually happens. Oh and regarding the goto statement, yes if your using them all over the place then i could understand ppl getting confused. But using a statment similar to goto BreakLoop: reads no differntly to reading the line break; As with any other statement if used incorrectly it can screw up the readability of your program but this can be said of practically any statement.
-
As VbStudent302 suggested Application.StartupPath is the way to go. By using Application.ExecutablePath you are returning the path complete with application name, which would essentially be telling it to do something like this.... C:\Documents and Setting\VB.Net\bin\application.exe\cinema.mdb instead of C:\Documents and Setting\VB.Net\bin\cinema.mdb On a side note I'm sure when I tried to use StartupPath when launching an application from a shortcut rather than direct from the exe I encountered some problems. It was probably almost a year ago now and after a quick test I can't emulate it, but I'm sure it used to return the path to the shortcut rather than the exe, was this changed in a newer version of the framework or did I just imagine it.
-
It would help if we could see your code, I can see no reason why you wouldn't be able to populate a ListView before the form is shown.
-
I respect your opinions, but I personally find the goto statement easier to read. So long as it is clearly labelled. The example I gave was very simplified as there are many points within the loop in which the loop needs to be exited. Obviously I could achieve this with a while loop and set a boolean value, but I guess i just find the for loops easier as thats what i'm used to. I guess i just view it as a logical step up from a for each statement (as i'm looping through a 2d array). I'm currently just an amateur coder, perhaps if I get a job as one I'll have to reform my ways. :)
-
As marble_eater says you can view the events of a control in the properties tab of the designer, the button your looking for is a lightning bolt. Then you can simply double click an event and it will attach the event and take you to the code view.
-
And your module is actually working? Isn't double only accurate to about 15 decimal places?
-
As you say there are many alternatives, I by no means intended to imply .Net Magic was the best solution, it was merely the only example I knew off hand (as the company I did my placement year at used it).
-
As far as I know the only way todo this is to buy a 3rd part user control such as the one included in .Net Magic (http://www.dotnetmagic.com/ - Crownwood Software), or by making one yourself.
-
I can't see why that wouldn't work assuming the Student objects have access to the database. I.e its not a member of MainForm.
-
Yes that would give a differen't result, but I have no intention of doing that. As the title stated I was trying to find the distance between 2 X co-ordinates not the difference between 2 points. The reason I'm doing this is because I'm creating a drag select for a program thus needing a rect object of the selected area (similar to the one in explorer). Todo this I need to work out how far the pointer has travelled in either dimension not in total. Otherwise I would have done as you suggested and applied pythagoras's theorum. :) Thus given Point pStart; Point pCurrent; the rectangle will be width = Math.Abs(pStart.X - pCurrent.X) height = Math.Abs(pStart.Y - pCurrent.Y) x = Math.Min(pStart.X, pCurrent.X) y = Math.Min(pStart.Y, pStart.Y) Rectangle rectSelection = new Rectangle(x, y, width, height); This method is far neater than the original rough method I was using to test selection which involved a couple of if else statements.
-
Compiling files into your exe - and then accessing them @ run time
Cags replied to Superfly1611's topic in Windows Forms
Do you wish to simply access them to copy them into a location on the end users PC? If this is the case then (I'm kinda guessing here I've not tested it), I'm pretty sure creating a Setup / Deployment project might allow you todo this. It certainly allows you to copy files to specified folders on the clients pc, quite how well it works when your not actually installing an application I couldn't say, but I think thats the way I'd attempt to do it. EDIT:- I gave it a quick test and it did what I wanted, also has the added advantage of adding an item in the add/remove dialog. This would allow an end user to remove the templates. -
I realised this as I said in my post, but PlausiblyDamps solution is far more elegant.
-
Excellent, thats exactly what I was looking for.
-
I'm trying to work out the distance between 2 points which is obviously done by doing X1 - X2. As the points can be either way around and I need a positive number i'm currently using an if statement to find out which is biggest. Then taking the smallest from the largest. Is there an easier way of ensuring the number is positive. Mathematically speaking I could just square then square root the number, but this doesn't seem any more elegant than an if statement. My current code... if(e.X > pSelStart.X) iWidth = e.X - pSelStart.X; else iWidth = pSelStart.X - e.X;
-
You can use Conditional Compilation Directives for this I believe. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_2_5_4.asp
-
What is the best way of getting out of a nested loop (using c#), I know that you can exit a single Loop with the break; command, for(int i = 0; i < iCount; i++) { if(RequirementMet) // situation on which I want to exit break; } but I'm unsure of the best way of exiting a nested loop, this is the way I'm currently doing it. for(int i = 0; i < iWidth; i++) for(int(j = 0; j < iHeight; j++) if(ReqruirementMet) goto BreakLoop; BreakLoop: Is this the best approach, I remember reading somewhere that the goto command isn't particularly good coding practice, but I don't know of any other obvious way to exit.
-
Add the code to the form constructor instead of the form_load event.
-
Hmm.. that works, unfortunately it uses numbers more than once atm, but with that as a start I should be able to work out a perfect solution.
-
Most newer games come with the ability to display thier own fps so depending on what your trying it might be easier to find that way.