Diamonddrake 397 Master Poster

Its a good IDE. but its not the only free alternative to Visual Studio for .net projects. besides the obvious Visual C#.net free from Microsoft there is also SharpDevelop. http://www.icsharpcode.net/OpenSource/SD/ I don't use it primarily as my preference is Visual studio. But its amazing and also open source.

Not knocking monodevelop. I have used all 3 of these and they all have their ups and downs, But they all are wonderful IDEs. I recommend Visual Studio first and foremost as it always supports the newest trends as soon as they are available. But otherwise, both SharpDevelop and MonoDevelop are great too.

I'm also a fan of snippetCompiler too, although i no longer use it because i wrote my own version that opens faster, supports more languages, and saves file tabs between session via a checkbox below the close button.

On another note, there is a free Adobe Flash open source IDE called FlashDevelop that is pretty nifty too. Its a good time for open software with the boom in computer science students about.

Diamonddrake 397 Master Poster

when you draw using the form's on paint method you are drawing directly to the form. any controls you create and add to the form are on top of the form. so if you draw on the form, the controls will ALWAYS be on top of your drawings.

you can't just draw a circle on top of multiple controls. If you need complicated drawing consider not using controls, but instead using rectangles and manually drawing all the needed elements of the composite.

Diamonddrake 397 Master Poster

It could possibly be the .net version you have installed on the XP machine. but you might try using the another method that uses reflection.

just replace this line

StartPath = Application.StartupPath;

with this one

StartPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

if it doesn't work on xp after that. It might be the .net version or a problem with your laptop. its all good code.

Diamonddrake 397 Master Poster

OK. you need to create a Class variable that is of string type. I will edit this source and post it back. there is no need to "reset" the startuppath.

using System.IO;
using System.Data;
// importing the OLEDB thing :P
using System.Data.OleDb;
using System.Windows.Forms;

namespace Login_Form
{
    public partial class frmAddMobile : Form
    {
        public frmAddMobile()
        {
            InitializeComponent();
			
			//Set start up path here.
			StartPath = Application.StartupPath;
        }

        // Global Areas Stuff - U Knw :D :D bt dnt ask me haridhaa :D ------------------------------------------------------

        // Global vars - new
        OleDbConnection dbcon;
        OleDbCommand com;
        string sql;
		
		//create string here in class to hold startuppath.
		string StartPath = "":

        // Creating the Onload event
        private void frmAddMobile_Load(object sender, EventArgs e)
        {
			//use startpath string instead of Application.StartupPath;
            string dbloc = StartPath + "\\G2.mdb";
            dbcon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+dbloc);
        }

        // Method Used to Clear The Text Fields
        private void FormClear()
        {
        }

        // Button & Combo Box Coding Stuff -----------------------------------------------------------------------


        private bool checkid(string id)
        {
           // i removed this code to make code look smaller ;)
        }

        private void btnSend_Click(object sender, EventArgs e)
        {

            if (txtMid.Text == "")

                // i removed if statements to make the coding bit smaller

            else
            {
               
                string mid, mmno, mprice, minfo, manu;
                DateTime doa;

                mid = txtMid.Text;
                mmno = txtModelNo.Text;
                mprice = txtPrice.Text;
                minfo = txtInfo.Text;
                manu = cmbManu.Text;
                doa = DateTime.Now;

                bool id = checkid(mid);

                if (id == false)
                {
			// removed if to make code look smaller ;)
                }

                if (txtPath.Text != "")
                {
                    FileInfo …
Diamonddrake 397 Master Poster

i don't think you followed me, if Application.StartupPath gives you the dir you need the first time you call it. Then you can save that path to a string. and then from then on out use that string instead of the Application.StartupPath.

The reason why it "changes" is because the working directory changes when you change it in a open or save file dialog box. But that doesn't matter because when the program first run you saved that data to a variable that WON'T change unless you manually change it.

its a class variable, available to the entire form.

If it didn't work, post the code that doesn't work. I will tell you why.

Diamonddrake 397 Master Poster

What's wrong with it? what is it suppose to that it isn't doing?

Diamonddrake 397 Master Poster

Welcome to the forum!
You have a couple options here. You can use reflection to get the executing path of the assembly. Or since you are new at it. I would just save that startup path to a string class variable. they use that from then on out. best place to do that is in the constructor.

public class Form1 : Form
 {
     private string StartPath = "";

     public Form1()
     {
       StartPath = Application.StartupPath;
     }

     ...
  }

Then just use that variable instead.

Diamonddrake 397 Master Poster

We aren't here to write your software for you. If you have erroneous code. Post it and we can find out why its not working.

Diamonddrake 397 Master Poster

I think your best bet here is to make your app run in the background with a system tray Icon. Using a timer and on its tick, subtract the time you started from the current time. then compare that a timespan.

attached is an example app project. I figured I'd need this for something eventually so I went ahead and hacked up and example.

Diamonddrake 397 Master Poster

Yeah, I tested it. It works fine. just don't put .exe on the process name.

IsProcessOpen("notepad");

another note. you might want to disable the update timer before you call the message box. otherwise you are going to end up with 10 message boxes before you get a chance to click ok.

Diamonddrake 397 Master Poster

first. 100 ms is way to frequent. you could save some processor usage by slowing that down to 1200ms.

2nd IsProcessOpen("notepad.exe"); according the comment in your IsProcessOpen method, it says not to use the ".exe" but instead use just "notepad"

//Be sure to not
//add the .exe to the name you provide, i.e: NOTEPAD,
//not NOTEPAD.EXE or false is always returned even if
//notepad is running.

Also you don't seem to do anything with the information after you find it.

Diamonddrake 397 Master Poster

I have posted a Visual Studio project that should cover any confusion.
Good luck.

Diamonddrake 397 Master Poster

we have already covered this.
http://www.daniweb.com/forums/thread273621.html

This is the same question. I don't understand.

Diamonddrake 397 Master Poster

According to the method definition for "tellme" that you show here, the 2nd param is of type Elephant. Which happens to be the type of the class that holds that method.

So when you call Tellme, and pass to it "this" you are passing a reference to the instance of an elephant class that the method is called from.

so when you call
lucinda.SpeakTo(lloyd, "Hello");
what is happen is, this method uses, lloyd(an instance of an Elephant) to get to its TellMe method. When you call the Tellme method of lloyd, you pass to lloyd the original method, but then it wants to know WHO sent that message(who called that method) So you say "THIS" since "THIS" is called from inside lucinda, THIS = lucinda who is of type elephant.

Sorry if I am confusing you. I hope you get it.

"this" always refers to the class you call it from.
If you are inside of a class, and you call "this" you are referring to the particular instance of that class as it is called at runtime.

So. if you are in lucinda, and you call "this" than this = lucinda.
if you are in lloyd and you call "this" than this = lloyd.

Also, the parameters aren't named very well to be easily undestood.
Instead of "talkTo" it should be ElephantToTalkTo. So when you pass lloyd, to the method, you are passing the elephant reference.

ddanbe commented: Nice explanation. +6
Diamonddrake 397 Master Poster

baeltazor, I see you are accustom to the .net baby sitter as much as I am. :). C and C++ people don't tend to use foreach loops often when the migrate to .net because its only possible in programming languages that use virtual machines like .net's CLR. But it actually adds an overhead, slowing down the execution of the code. Plus your version of the code requires creating an addition object, that takes time to initialize, takes more system resource, and twice the memory.

Not that its a bad way to do it. computers these days are plenty fast and for each loops and they are very fun and easy to use.

But even though its less typing, technically the OP's way of doing it was "faster" by terms of the program execution.

Diamonddrake 397 Master Poster

Could you please explain in detail what you are trying to accomplish?

Diamonddrake 397 Master Poster

*sigh*

string path =  Application.StartupPath;
string subfolder = @"\Images\";
string imagefilename = "myjpeg.jpg";

pictureBox.Image = Image.FromFile(path + subfolder + imagefilename);
Diamonddrake 397 Master Poster

I have never heard the term "Push Tech" but To my knowledge most chat applications go through the server for everything. But there is a possible peer to peer relationship that can be established.

Normally. The client messengers contact the server. the server has a thread pool of sockets blocking waiting to accept new client connections. Then once the handshake is made, the socket with the client connection is passed to a thread pool for redirecting messages. And the client's login name is added to a list. Then when a client sends a message to another client. It actualy is sending the message to the server like"attention:client name: message" the server then write that message to the socket for that intended client. The client has a thread constantly blocking on a socket read waiting for new mesagges. once it gets one it shows it to the user and goes back to blocking on a socket read. and the gui thread is always open to write outgoing messages or update the display.

now in a server logged peer2peer situation, Clients connect to a server just to tell the server where they are, who they are, and what they can do, and get a list of that information about other logged in clients. So then each client has the information it needs to make a direct connection to other clients. But this requires ports to be opened and other hassles. But it keeps the load off the server, so a …

kvprajapati commented: Indeed. +9
Diamonddrake 397 Master Poster

The previous poster did a good job at answering your question. But I am here to tell you why what you tried didn't work.

your code

List<TSQLBeginTransactionBlock_Ext> tempBeginTranList =new List<TSQLBeginTransactionBlock_Ext>();
tempBeginTranList = beginTranList;

Now its important to know that when you create a variable with a type. You are really creating an object reference, or object pointer.

when you say List<TSQLBeginTransactionBlock_Ext> tempBeginTranList what you are saying is, create a reference by the name TempBeginTranList, and have it always point an object of type List<TSQLBeginTransactionBlock_Ext>.

now when you say TempBeginTranList = new List<TSQLBeginTransactionBlock_Ext>(); you are saying the TempBeginTranList object reference should point to a new instance of List<TSQLBeginTransactionBlock_Ext>. which is created by calling that constructor method with the keyword new.

but when you say. tempBeginTranList = beginTranList; you are actually saying the Object reference tempBeginTranList should now point to the object beginTranList is pointing at, So now both of them are pointing to the original object in memory. and the List you created with new and assigned to TempBeginTranList original now has no references, and is both lost, and eligible for garbage collection.


Any time you want to create another object. you need to use that word new, now assuming all the properties of the objects are public you can use reflection to loop through the properties in a type and duplicate it. Since your object is a list it makes it MUCH easier.

List<TSQLBeginTransactionBlock_Ext> tempBeginTranList =new List<TSQLBeginTransactionBlock_Ext>();
tempBeginTranList.AddRange(beginTranList);

so now the …

Diamonddrake 397 Master Poster

there are quite a few ways to do this, simplest

string path =  Application.StartupPath;
//This gets the directory the application was started from.

And more complicated, but many people will tell you this is the only correct way, I argue against that. but it certainly does work also.

string correctPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
Diamonddrake 397 Master Poster

you aren't adding the new picture box to the form's controls collection, so it doesn't get painted.

after you set the new picturebox's properties. add

This.Controls.Add(pictureBox);
Diamonddrake 397 Master Poster

in sudocode:
onPicturebox MouseDown:

create new picturebox

set new picutebox's size, location, and image properites
to match the old picturebox

StartDraging code moving the new picutebox not the old one.

onMouseUp leave new picutebox where ever you left it/ want it.

Diamonddrake 397 Master Poster

A graphics object is sealed. It cannot simply be instantiated. you can create one from an image to use to draw to the image, but as far as painting to a form or control, you are pretty much stuck using Paint events. But that's the extent of their usefulness anyway.

Diamonddrake 397 Master Poster

I figured it out. Needed to create params for WS_Child, WS_THICKBORDER and then WS_EX_NOACTIVAVE and WS_EX_TOOLWINDOW.

I did this trial and error for an hour before I got what I needed. Also important to note. Setting the location of the form didn't seem to move it. so setting the size int the override create params worked for setting the initial position.

here is a dirty drop in solution for anyone else who needs this.

const int WS_EX_NOACTIVATE = 0x8000000;
        private const int WS_EX_TOOLWINDOW = 0x00000080;

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams ret = base.CreateParams;
                ret.Style = (int) WindowStyles.WS_THICKFRAME | (int)WindowStyles.WS_CHILD;
                ret.ExStyle |= WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW;
                ret.X = this.Location.X;
                ret.Y = this.Location.Y;
                //ret.Parent = IntPtr.Zero;
                return ret;
            }
        }


        [Flags]
        enum WindowStyles : uint
        {
            WS_OVERLAPPED = 0x00000000,
            WS_POPUP = 0x80000000,
            WS_CHILD = 0x40000000,
            WS_MINIMIZE = 0x20000000,
            WS_VISIBLE = 0x10000000,
            WS_DISABLED = 0x08000000,
            WS_CLIPSIBLINGS = 0x04000000,
            WS_CLIPCHILDREN = 0x02000000,
            WS_MAXIMIZE = 0x01000000,
            WS_BORDER = 0x00800000,
            WS_DLGFRAME = 0x00400000,
            WS_VSCROLL = 0x00200000,
            WS_HSCROLL = 0x00100000,
            WS_SYSMENU = 0x00080000,
            WS_THICKFRAME = 0x00040000,
            WS_GROUP = 0x00020000,
            WS_TABSTOP = 0x00010000,

            WS_MINIMIZEBOX = 0x00020000,
            WS_MAXIMIZEBOX = 0x00010000,

            WS_CAPTION = WS_BORDER | WS_DLGFRAME,
            WS_TILED = WS_OVERLAPPED,
            WS_ICONIC = WS_MINIMIZE,
            WS_SIZEBOX = WS_THICKFRAME,
            WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW,

            WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | 

WS_MAXIMIZEBOX,
            WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU,
            WS_CHILDWINDOW = WS_CHILD,

            //Extended Window Styles

            WS_EX_DLGMODALFRAME = 0x00000001,
            WS_EX_NOPARENTNOTIFY = 0x00000004,
            WS_EX_TOPMOST = 0x00000008,
            WS_EX_ACCEPTFILES = 0x00000010,
            WS_EX_TRANSPARENT = 0x00000020,

            //#if(WINVER >= 0x0400)

            WS_EX_MDICHILD = 0x00000040, …
Diamonddrake 397 Master Poster

OK, I have made a small breakthrough. but it doesn't help me. The window Given WS_EX_NOACTIVATE responds correctly as long as no other windows from the same application that don't implement WS_EX_NOACTIVATE have focus.

That is to say, if I have a form that has a button that spawns WS_EX_NOACTIVATE forms, those forms act normally until the main form is minimized. then they act as expected. maximize the main form and they act normal again.

any ideas why? I need the WS_EX_NOACTIVATE window to display infront of the main window allowing me to choose data without leaving the focus of my text box.

Diamonddrake 397 Master Poster

I have been looking for the answer for 7 hours. So a quick google isn't going to cap this one. I Am working on a programming notepad app with intellisense like Visual Studio. only I have run into a big issue. In Visual studio the little intellisense window is its own form. Thats no problem, But notice that the little window doesn't take focus when it opens. Thats no problem either right? ShowWindow with a shownotactivate flag. but NOTICE that when you click on the little window. it changes selection but STILL doesn't activate! I can't seem to reproduce that.

I found a exStyle called WS_EX_NOACTIVATE. All over the net it says this does what I want. And in fact it DOES! but only if its created on the MAIN form of an application. have 2 or more forms, if they aren't all WS_EX_NOACTIVATE, then none of them are. End of story.

If someone could show the light, on how this could be done in C#. I would appreciate it. I'm about shot. I don't want to give up. But I might have to use a floating List view like the rest of the internet community has. I just really would like to see this work.

Keep in mind that I am using windows 7. some of the code examples I have found might work on older systems. but not mine. Also. however Visual studio does it, it works on windows7.

try this.

using System; …
Diamonddrake 397 Master Poster

This simple class encapsulates the exAnimatewindow api call. I got tired of adding all the jazz to every form I need to use as a pop up, or any borderless forms I used. (Windows 7 and vista don't animate windows with no border by default)

This class could easily be expanded to offer all the animation directions and types But I included just the ones I use most often. I like a small footprint. No need for code you don't use. So just expand it if you need more functionality.

here is the simple usage. Just throw this line in the constructor of the form you wish to animate.

DDFormsExtentions.WindowAnimator DDwa = new DDFormsExtentions.WindowAnimator(this, DDFormsExtentions.WindowAnimator.AniType.SlideDown, 200);
kvprajapati commented: Wonderful! +9
Diamonddrake 397 Master Poster

IDK about that one. COM works with running apps. but I'm afraid that's where my usefulness here looses speed. Sorry. Hope you find your answer.

Diamonddrake 397 Master Poster

Yes you can. That's what I explained before. Create a public class with a pubic method GetBookReference(string book) or whatever you want. Compile it. and start a new application. Click on references. Click new reference. and browse to the first exe. then use the GetBookReference(string book) method. That simple. Just try it

that is assuming that you are using Visual Studio 2008. I believe older versions of Visual studio limits you to .dll even then you can manually add a reference using compiler arguments.

I just tested it in Visual studio 2008 to verify that it works, and it does.

Diamonddrake 397 Master Poster

The System.Drawing name space holds a class called Image. It is used as a type and has instance methods. It cannot be directly initialized but is easily used a runtime.

Image pic = Image.fromFile("path to image");
then you can show the image anyway you like, as the image property of a picturebox or in a drawimage method in the paint event.

or even short cut it. Picturebox1.Image = Image.FromFile("where file is");

But more importantly the picturebox has a ImageLocation property that is a string. set that to a path to a file, and it will load the image.

All of these methods work from run time, not build time.

Diamonddrake 397 Master Poster

the 2nd form should expose the selected data as properties. when the user has set the values they wanted. the dialogresult property should be set to OK. and the form closed. Nothing else needs to happen in the 2nd from. The main form will still have a reference to the 2nd form and be able to get its data.

Diamonddrake 397 Master Poster

The dialog modal of programming suggests that you get the data from the edit dialog back to the main form. not the other way around. your OK button should just close the form with the dialogresult property set to true. and expose the color font and text from the edit dialog as properties. Then do it all in the method that calls the edit dialog.

//code on main form.
    private void toolStripButton1_Click(object sender, EventArgs e)
    {
        EditText myNewForm = new EditText(); 
       if(myNewForm.Showdialog() == dialogresult.OK)
       {
          Image img = picturebox.image;
         Graphics G = Graphics.FromImage(img);
         G.DrawString(myNewForm.BodyText, myNewForm.BodyFont, new SolidBrush(myNewForm.BrushColor), new PointF(0, 0));
          G.Dispose();
          picturebox.image = img;
           picturebox.Invalidate(false);
       }

}

Keep in mind this code is for example only, written here to explain the concept. It doesn't have correct names for your project, assumes changes are made that aren't shown to the original code, contains spelling and capitalization errors, etc. Give you the idea of how it should look though.

Diamonddrake 397 Master Poster

call the open file dialog box in the program's Main method. if its a success then call the application.run method passing the filename to the form's constructor. if its not a success then simple allow the main method to return closing the program.

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Serial
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1(ofd.FileName));
            }
        }
    }
}
Geekitygeek commented: word for word what i would have post :p +1
Diamonddrake 397 Master Poster

Saving reading every line of code here. I think what you are going for is to expose the values your text dialog has as properties. and when the method that calls it returns, get those values and apply it to the image and refresh the picturebox.

Diamonddrake 397 Master Poster

Message/Event driven game structures are a great way to write games, Unfortunately I don't have any good links. There are quite a few books on the subject although I'm unsure how many of them are leaned toward C#.

Diamonddrake 397 Master Poster

Still unclear what you expecting. Do you just want to draw a rectangle with your mouse?

"this is something you can do easily with flash" Unfortunately flash is a scripting Language on a multimedia platform. C# can be so much more than a program trapped in plug-in. But that comes with having to learn more than just how to manipulate multimedia.

if you could explain exactly what you want to do, we can help you figure out how to accomplish it.

Diamonddrake 397 Master Poster

This is so vague. what defines a "particular part"? the idea is to just create a rectangle at "some particular location" then create a graphics object from the image then call its FillRectangle() method.

Diamonddrake 397 Master Poster

Although that looks like it would work, if you were going to do it like that, you might want to sleep that thread for 1 to 3 ms in those empty while loop to take some CPU time priority off that empty loop.

I don't think that would be the best way to write a monopoly game as that would be best a event driven game, not a loop driven.

but doing so in a basic background loop is not a bad way to go about it, There are several ways to do this. one, the if statement system I was talking about before would work fine. but adding an int that would keep track of which method the loop is on. then using a switch to call the correct method, then incrementing the current fucntion int.

backgroundMethod()
{
 int stepCount= 0;
while(running)
 {
   if(!Paused)
     {
                        switch (stepCount)
                        {
                            case 0:
                                Function1();
                                 stepCount++;
                                break;
                           case 1:
                                Function2();
                                 stepCount++;
                                break;
                            default:
                                stepCount = 0; //if were out of functions start over
                                break;
                        }
     {
  }
}

Lots of ways to go.

or instead of those while(paused)[//do nothing} statements, replace them with if(paused){monitor.wait}; That would block the background thread until the main thread called monitor.pulse which would resume it.

Of course all these ways would only pause the game after each of those possibly very complicated game methods returned.

Lots of possiblilites

Diamonddrake 397 Master Poster

I think I get what you are talking about. :)
The best way I know to use a combo box is to bind it to an enumeration.

Bind Combo Box to Enum
That's a great link to get you started. Then when you want to retrieve the value and use it to decide what to do. Then you can use a switch statement. makes for ease of use.

Post back if you need more clarification. pretty simple but if the idea is too abstract I can create you an example project that shows what I mean.

Diamonddrake 397 Master Poster

Then I am afraid you might have to rethink your game logic. pausing a huge set of tasks can be a huge task in it's self. And the entire game logic should be written around the idea that it needs to check for a paused flag.

Without any more information its hard to say. I wish I could be more help. Sry.

Diamonddrake 397 Master Poster

it would be helpful if you just post your project. we can find out what is really going on.

Diamonddrake 397 Master Poster

if your functions need to be continuously called in a loop i would do something like this.

backgroundMethod()
{
while(running)
 {
   if(!Paused)
     {
       Function()
      Function2();
      Function ect...
     {
  }
}
Diamonddrake 397 Master Poster

this isn't very clear. But with only this information i would say check the file extensions on the path. if its .PDF then obviously, and if its .jpeg, .gif, .png, .bmp, ect. then its an image.

Diamonddrake 397 Master Poster

Some thoughts on this:

1) When using multiple forms for 1 application, its advantages to use MDI. Most users like to feel they have control over what they are doing and a bunch of floating forms can be scary if they don't behave the norm. Typically the "Main" form is just a container. and then multiple other forms populate that space with information.

2)in the Main method of the application the static application class's "RUN" method gets called. this is what creates the message loop that keeps your main method from returning until the Message Loop is exited. In your Main method you will see that the run method is taking a new instance of your main form. This means that the message loop is tied to the life of that instance. when you close it. "RUN" returns and the Main method returns.
You could easily create a new form and show it then call and empty RUN() method, then when the forms close the app would stay running until the process was killed externally. Or create a ApplicationContext that would tell the program what to do when a form is closed.

Diamonddrake 397 Master Poster

seems like the while loop is the way to go. maybe stick some of the function calls in a if(!paused) statement?

That always worked when I wrote flash games. Haven't written a game in C# yet. Although I hear XNA has a good thing going.

Diamonddrake 397 Master Poster

As long as the methods don't need the application to be running to work, then you simply put them in a public class, and make the methods public, then reference the .exe from the new app. and all its public classes and methods will be available to other applications.

Diamonddrake 397 Master Poster

Create a Static Class and make the method static. Then at any time in the application you simply call it [I]Classname[/I].[I]Methodname[/I]([I]parms[/I]); . that easy.

Diamonddrake 397 Master Poster

have you tried Thread.Suspend(); / Thread.Resume(): ?

Diamonddrake 397 Master Poster

Those guidelines were written by some cleaver programmers, There is no "official" standard. But there is always the Standard microsoft uses in its coding examples on MSDN.

I would argue to the OP that I don't think alphabetical is the best practice or even relevant. If you use Visual Studio (and everyone should because its amazing) you will notice that there is a combo box at the top of ever code view that lists all the members of the current document in alphabetical order. click on one and you are there.

Not saying that coding practice's aren't important, Because its very important that you are consistent. I Just don't feel that the order of your code should at all be based on access modifiers. Nor do I feel that all members with similar access modifiers even be kept together.

Best of luck. Learning to keep your code clean at the beginning can lead to a career of easy to review code.

Diamonddrake 397 Master Poster

That's up to you or whoever reviews your code. If you write apps alone. Its whatever is easiest for you.

Personally I order code by relevance. I create some regions and put similar things together. I put the private variables and the public properties that expose them right next to each other in a vars and properties region. I put the load event toward the top, and the on closing event toward the bottom.

When the program compiles its all one big sheet of code anyway. There isn't a right way. (unless you work for a company that cares, in which case, do what they ask)