zachattack05 70 Posting Pro in Training

I'm working on a databound CheckListBox and things are going well, but the name I chose for it is bugging me.

Because the control CheckListBox already exists, I didn't want to name it that, and instead chose P_CheckListBox (the P represents the first letter of the company name) and is stored in a DLL of its own, but I'm just not sure, the P_ prefix will allow for nice grouping in the intellisense but I just have a feeling it's not a good thing to do.

How do you name your custom controls that derive from, or logically would have a name of, an existing control?

Oh, also, when creating a custom control, is there any performance change if deriving from UserControl and placing one control that is Dock:Fill on the surface, or just deriving directly from the control itself?

zachattack05 70 Posting Pro in Training

Good point Thines, I knew that, but for some reason didn't think of it.

Also, I'll check out the subversion software and see what it's all about.

Thank you both!

zachattack05 70 Posting Pro in Training

I was thinking that in the future I might be updating some of my class libraries and when I do that, it might be useful to keep old classes, namespaces and objects in the updates just for backwards compatability.

I was wondering what you guys and gals thought of naming classes and namespaces with version information? For example a namespace might be MyCompany.MyApp.ControlLibrary.V1 or MyCompany.MyApp.ControlLibraryV1 or some other variation.

The reason I was thinking about this is, if I needed to update say, a class, and the update was basically a very large re-write (or total re-write) and I wanted to keep the old one there for backwards compatability, the name of the class would already be taken, wouldn't it be better to version everything like that so it would be ControlLibrary.MyTextboxV1 instead of just ControlLibrary.MyTextbox? That way the functionality of the first version isn't lost, and unnecessary code isn't needed in the methods to jump around code depending on the application version?

Thoughts?

zachattack05 70 Posting Pro in Training

What is a Pie menu?

zachattack05 70 Posting Pro in Training

I think I may have actually figured it out.

I had an epiphany when reading about the INTERSECT statement.

I simply created a temporary table, copied all of the locations for a given account into that table, then updated my "Checked" column using the IN operator on a query that selected the list of locations for a given account and contact.

While that probably makes absolutely no sense since you can't see my database schema...it works! I'm beyond excited! Woo hoo!

zachattack05 70 Posting Pro in Training

I can't seem to wrap my brain around this one and would really appreciate it if someone has some suggestions! :)

I have two tables, one contains a list of locations (AccountLocations), another a list of contacts that belong to those locations (AccountContacts).

What I would like to do is create a derived table (I'm assuming) that will list all of the specified locations for a given account, and at the same time, check to see if a given contact belongs to each of those accounts, and if it does, switch a bit field in the derived table to True.

Here's an example:

AccountLocations Table
---------------------------------
| ID | AccountID | LocationName |
---------------------------------
| 1  | 1         | Location 1   |
| 2  | 1         | Location 2   |
| 3  | 2         | Location 3   |

AccountContacts Table
--------------------------
| ContactID | LocationID |
--------------------------
| 100       | 1          |
| 500       | 1          |
| 200       | 3          |
| 400       | 2          |

If i provide the Stored procedure with the variables of 1 for the AccountID and 100 for the ContactID, the resulting table should be:

Results Table
---------------------------
| BitField | LocationName |
---------------------------
| True     | Location 1   |
| False    | Location 2   |

Basically the query would copy all of the possible locations to the results table, and then one by one, go through those locations and "tick/check-off" each one that a given contact belongs to.

Does that make …

zachattack05 70 Posting Pro in Training

No no, I don't think you understand what I'm trying to do.

It's not a web program, it's a WinForms program and I don't want to create and send an email message. All I want to do is if the user clicks a button my application will tell the operating system to open the default email program with a new message addressed to a certain person.

This has to be an option somehow, considering you can "register" with the operating system a default email client. Assuming that you can set a default client, that must mean that there has to be a way for other applications to tell the operating system "Hey, open the default email program" and the OS can do that even though the application asking the OS to do that has no idea what application that is.

So, assuming the command the OS gets to open the default email client is "open email client" if my application tells the OS to do that on a computer with Outlook 2007 installed and set as the default email client, that is the program that will open, and if it's Thunderbird that will open...etc...

I don't want to send it, just open it.

zachattack05 70 Posting Pro in Training

Dunno if anyone knows about this comic but it is hillarious and highly recommend it for a good laugh. It's written by a former NASA employee. Here are a few of my favorates (it's licensed under the CCL so the images are cool) you can read it at XKCD.com :

sandwich
exploits_of_a_mom
ballmer_peak
compiling
real_programmers

zachattack05 70 Posting Pro in Training

I guess what I am trying to do is offer the convenience to the user, that if they want to send an email to someone in my application, instead of Copy, Open email, Open new message, Paste in 'To:' field, type message, Send" they can just "Click, type message, send"

zachattack05 70 Posting Pro in Training

I'm not trying to "send" an email message, but rather, in a directory of email addresses, when a user clicks the email address or a button, the user's default email client (Outlook, Gmail, Windows Mail, Thunderbird, Netscape Messanger (does that even exist anymore) or whatever...) will open a new email message, or at the very least start the application, and if a new message is created, pre-fill in the "To:" box with the email address they clicked. No message, no subject, no sending, just open, and put the email address in the "To:" field. That's it.

I figured since most computers today have some sort of email client that will open by default when a user clicks an email address in a webpage, I thought that since the HTML for an email link was "mailto:" that if I called that as a process, it would start whatever process handles the "mailto:" protocol.

zachattack05 70 Posting Pro in Training

I've been reading about various methods of how to do this, but I wanted to ask if something will work or not and was hoping someone could be kind enough to test this out for me.

I do not have an email client (Outlook etc...) and just use Gmail.

If I would like to include a button/link whatever, that a user can click and open their default email client, will this work without importing anything or using some custom class:

        System.Diagnostics.Process.Start("mailto:" + emailTextBox.Text);

when I use that, it opens Gmail on my computer and has a blank message pre-addressed to whatever is in the textbox. Will this work with Outlook or other applications or is it just that since Gmail is web-based it works?

zachattack05 70 Posting Pro in Training

LOL!

Not sure why it did that, but that's kinda funny.

Anyway, I did know about the F12 trick. I don't use it that often, but maybe I should, and also that little drop down at the top I guess as well. I just need to get used to doing it that way.

Thanks for the tips!

zachattack05 70 Posting Pro in Training

I appreciate the feedback!

I do divide my code using regions, I group things similarly to how Momerath does. It works well, but it's kind of a drag when the file is nearly (or over) 1000 lines and you need to find a method in the middle of the file for whatever reason and you scroll.....slowly....until you find it. I just wish there was a way to change the background colour of every other method or something, or highlight the text inside of a region with some sort of color you could set, like #Region Some Name [BG:Red] or something so that, without looking at the top of the region to find out what region you are looking at.

I know, I know, the code should be obvious just by looking at it what region it's in, but if I was looking for the red region, I could scroll faster until I just saw red, and knew it was the one I was looking for.

Oh well.

I do appreciate the feedback though! What colour schemes do you guys use for your code editor? Or do you just use the default (that's what I use).

zachattack05 70 Posting Pro in Training

Ahhh, yeah I thought about that, but wasn't sure. Still bizarre to me :) Thanks for the clarification!

zachattack05 70 Posting Pro in Training

Was writing a new method to open a custom dialog box I created, and realized that the other method I wrote to open another custom dialog had the same name as the object representing it, but there was no error?

This is what I mean:

Originally the code read:

        Dialogs.Accounts.NewLocation LocationEditor = new Dialogs.Accounts.NewLocation();
        LocationEditor.ShowDialog();

And after the editor evolved I decided to reuse the same form for creating new locations and editing existing ones, so to make the name of the form match it's purpose I changed it from NewLocation to LocationEditor. Now the code reads:

        Dialogs.Accounts.LocationEditor LocationEditor = new Dialogs.Accounts.LocationEditor(SelectedLocation, false);
        LocationEditor.ShowDialog();

There's no error with this? I don't get it, I thought this wasn't allowed? The object's name is LocationEditor and the instance of that object is LocationEditor...same name, same casing...I'm confused, if the method was longer than about 6 lines and the object was used over and over, how would the compiler know what I was talking about, the original object or the instance that already exists? Either way I'm going to change the name of the instance, but I just never caught this until now and just found it odd that it worked.

zachattack05 70 Posting Pro in Training

I have a few code files that are rather large in length. The one I have open right now is approaching 750 lines and is growing quickly. I'd rather not split the class among multiple files, doing that just makes me nuts (even when VS puts the control declarations in the separate file makes me nuts, I wish I could turn that off), having to move between tabs to compare code (yeah I know you can split the screen but that makes me even crazier).

I was wondering if anyone had any tricks to make it easier to find methods or regions in the code file without searching forever. Either colour schemes or anything!

I'm one of those code writers that people seem to hate looking through my source, just because I LOVE space. I always put my brackets on a line of their own, my "get set"s used to take 8 lines, now they just take 4, but that's still a lot for some people.

I also had a bad experience once of reviewing code that I had written back in 2008-2009 and practically documented nothing, except for obvious things, and even then the comments were useless, like before a confirmation message box I'd put "Make sure the user isn't an idiot!"

I've gotten into the habit of documenting the purpose of methods (XML Comments) and parameters etc.. but only comment unobvious things inside my methods. But I'm worried that I'm not documenting enough, because what's obvious now, might …

zachattack05 70 Posting Pro in Training

thines01,

Thats what I thought!

Yes the ID column is a identity,PK index for the table. It appears that VS knows this, but I guess it feels the need to make it complex. Here is the property grid for the ID column of that table as it appears in VS:

IDPG

Oh well, I don't get it. It always seems to do that, I just never paid much attention.

zachattack05 70 Posting Pro in Training

It just occured to me that when I go to create a new SQL query using VS's query builder, it pre-fills in a query based on the datatable I am building the query with. Normally I just delete the standard query (unless it's sufficient) and write my own, but this morning I was creating a new query to delete a row from a table. Nothing all that complex, and nothing new, I've done it many times, but the pre-filled query is so ridiculously (in my opinion) complex that I thought I might be missing something important.

This is the query that it originally offered up this morning:

DELETE FROM AccountLocations
WHERE        (ID = @Original_ID) AND (@IsNull_AccountID = 1 AND AccountID IS NULL OR
             AccountID = @Original_AccountID) AND (@IsNull_LocationKey = 1 AND LocationKey IS NULL OR
             LocationKey = @Original_LocationKey) AND (@IsNull_LocationName = 1 AND LocationName IS NULL OR
             LocationName = @Original_LocationName) AND (@IsNull_FileAs = 1 AND FileAs IS NULL OR
             FileAs = @Original_FileAs) AND (@IsNull_SyncAddresses = 1 AND SyncAddresses IS NULL OR
             SyncAddresses = @Original_SyncAddresses) AND (@IsNull_PhysicalAddress = 1 AND PhysicalAddress IS NULL OR
             PhysicalAddress = @Original_PhysicalAddress) AND (@IsNull_PhysicalCity = 1 AND PhysicalCity IS NULL OR
             PhysicalCity = @Original_PhysicalCity) AND (@IsNull_PhysicalState = 1 AND PhysicalState IS NULL OR
             PhysicalState = @Original_PhysicalState) AND (@IsNull_PhysicalPostalCode = 1 AND PhysicalPostalCode IS NULL OR
             PhysicalPostalCode = @Original_PhysicalPostalCode) AND (@IsNull_PhysicalCountry = 1 AND PhysicalCountry IS NULL OR
             PhysicalCountry = @Original_PhysicalCountry) AND (@IsNull_MailingAddress = 1 AND MailingAddress IS NULL OR
             MailingAddress = @Original_MailingAddress) AND (@IsNull_MailingCity = 1 …
zachattack05 70 Posting Pro in Training

Hmmm then something else is going on somewhere...back to bug hunting :/

Thanks for the help!

zachattack05 70 Posting Pro in Training

No I don't want to hold multiple values.

I guess what I am asking is does a variable that get's a value via a method get the actual value or does it basically have a reference to the method that provides the value?

zachattack05 70 Posting Pro in Training

No I don't think you understand...here's an example:

Assume:

private bool MyMethod()
{
   if (MyInteger > 0)
      {
         return true;
      }
   else
      {
         return false;
      }
}

if I call the following in a method:

private void SomeOtherMethod()
{
   // earlier code
   
   int MyInteger = -100;

   bool MyValue = MyMethod();  // MyValue should be false here

   MyInteger = 100;  // Is Myvalue still false now?

   // more code
}

Because the value of MyInteger changed, and would, therefore change the return value of MyMethod(), does it actually change it, or is MyValue still false after MyInteger gets a new value?

zachattack05 70 Posting Pro in Training

I'm sure I know the answer to this, but I just want to double check because I'm doing some debugging and I want to rule this out.

If I set the value of a variable with something like bool MyValue = MyMethod(); and initially the return value of MyMethod is False, but a few seconds later the value changes to True, and I refer to MyValue later, does it keep it's inital value of False, or does it re-evaluate it each time?

I'm under the impression that it does not change and should stay False, and that only if I use get; set; and in the get accessor I return MyMethod() will the value update itself...is that right? Because it doesn't seem to be doing that unless I missed something else that is changing the value.

zachattack05 70 Posting Pro in Training

Wow that's actually a very good point that I never considered!

I think the concern about rewriting a class that has already been written is a valid point, but could happen with any class, even if a dll already exists for it.

I did think about the problem of giving stuff away. While I would say 90% of the people out there who purchase software, aren't even aware of dlls, or if they are, have no concept of what they do. It's the 10% that know enough to fiddle around and possibly get your source only to find it was a present full of even more than they expected. I'd like to prevent that as much as possible, without losing my mind, but it is a very good point.

I was on the fence as it is, I think I might stick to that idea of creating simpler dlls instead of a huge catch-all collection.

zachattack05 70 Posting Pro in Training

Greets again!

I am working on a project and have some controls that I have created, and even some full namespaces that I think would be very useful to other projects I am working on and possibly future ones.

I'm considering pulling the code for those namespaces/controls out of the project, creating a library and just linking the project to the library.

The question I have is at what point does it get excessive? I know this probably sounds like a subjective question, but I am talking mostly about objectively, the performance, the wasted space of delivering a dll to end users where certain controls may or may not be utilized?

For example, if my library has a namespace called .Windows.Forms the same as the MS System namespace has, and I include in that namespace, objects, classes etc. that can be used on forms like textboxes that perform certain validation, or more complex controls/classes, at what point is it a bad idea to include in a project a library where only one or two of potentially hundreds of classes/controls are used?

Is there much of a performance change (regardless of code quality) in a 300K library compared to a 3MB library?

For efficiency in development, deployment and maintenance, I would think a single library with many classes is preferred rather than many small ones. Obviously if they serve different purposes that's one thing, but throwing an entire namespace into a library seems like it …

zachattack05 70 Posting Pro in Training

Thanks for the replies!

That explains a lot! I had never heard of lazy loading! Thanks for the info!

zachattack05 70 Posting Pro in Training

So the question is, if I am instantiating a control for use on a form (or any object really) at what point is the object and it's properties/methods considered loaded into memory?

The reason why I ask is because evidently when I instantiate my custom controls, but before adding them to the form, they are not "loaded" and the Load event is not triggered until I explicitly add the control to the form.

For example, the code MyControl myControl = new MyControl(); does nothing, but as soon as MyForm.Controls.Add(myControl); is called, the load event for MyControl is triggered. Is this odd to anyone else? If the load event is not triggered at instantiation wouldn't the event name be kind of deceiving? I mean, an instantiated object, by definition is loaded, isn't it?

zachattack05 70 Posting Pro in Training

I actually thought that an interface was a "tool" to create a bridge between one object type and another and make things that otherwise are completely unrelated, related. Like a Japanese speaking person learning English, and a French speaking person learning English and the both of them meeting in the United States to conduct business together in English. English allows the two of them to conduct business though an "interface" of sorts. If both don't use or implement English, then they really can't conduct business together except on a very basic level (public and static methods etc...). If both knew English then they can conduct business easier. But since one doesn't know the others native language, they can only use the tools provided by the interface.

An abstract class to me appears to be a new base to start from. The reason the two people above had to use an interface to communicate is because the languages are different, but every language shares some of the same basic rules (abstract). These basic rules are rules that every language must follow, but Japanese and French evolved separately and can continue to evolve over time, but they both still share the same exact rules that they originally started with.

Is that right? I don't see how there could be debate if that is correct. An interface and an abstract object to me are totally different and serve totally different purposes.

zachattack05 70 Posting Pro in Training

Strike that!

I re-read your post and re-read the MSDN docs.

Looks like abstract classes can have abstract methods and normal methods...For some reason I thought they couldn't, but I guess that would make them interfaces instead...my bad.

Thanks as always!

zachattack05 70 Posting Pro in Training

Momerath,

Yeah, that's true. But can an abstract class contain methods that are already implemented, and contain methods that are not implemented, but would need to be implemented by the classes that inherit it?

For example, the "base" wizard class would contain methods that would load, sort and process the showing and navigation of the various steps. These methods would already be written, the classes/forms that inherit it wouldn't need to implement those methods, and in fact should be an error if they try to.

Here's an example:

Let's say we have a form called BaseForm. It has a method called BaseFormMethod() . The BaseFormMethod() is already implemented and is sealed. However there is also a another method called LoadSteps(IWizardStep[] stepArray) which is NOT implemented in BaseForm, it is just an empty method.

Now, we have another form called SomeWizard which inherits from BaseForm. I want SomeWizard to have to implement the method LoadSteps(IWizardStep[] stepArray) on its own, but NOT implement BaseFormMethod() because it is already implemented. The SomeWizard form can call BaseFormMethod() and LoadSteps() simply by calling it like normal, but the developer would not have to write the BaseFormMethod() because it was already written and is automatically in ALL wizards that are inheriting from BaseForm, and by changing the BaseFormMethod() in BaseForm, all of the Wizards that inherit from it would also change without making any modification to those forms individually.

So it's kinda like, I need a form that has x, …

zachattack05 70 Posting Pro in Training

Hi again!

I was hoping someone would be kind enough to throw some advice my way here.

I'm working on an application (still) that I would like to provide "Wizards" in. I have a general idea of how I would like to implement something like this, but staying in line with OOP, I would like to have a base class that derives from a form (basically a form) with some standard controls, buttons, progress bar, and a "canvas" area for the wizard steps to show.

The idea is that I would have a single form that would act as the base of the wizard, or the Host. This form would be partially implemented having some methods that cannot be overridden so that basic functionality applies to all wizards.

The developer would then, if a wizard was needed, create a new form that inherited from this partial form. Certain properties could be set (like the text to show on the buttons, whether or not to allow canceling out of a wizard, should a progress bar be visible etc while others could not be.

When the developer creates the inherited form, just like an interface, they would need to implement the "interface" of the form they inherited from.

I hope this makes sense...

Another way of saying it would be that I would like to create a form that has certain methods and properties, some that can be overridden and some that cannot. The form …

zachattack05 70 Posting Pro in Training

Nevermind! I figured it out.

According to the MSDN documentation, controls follow this event pattern when focus is changed, thereby causing validation:

When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the Select or SelectNextControl methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order:

  1. Enter
  2. GotFocus
  3. Leave
  4. Validating
  5. Validated
  6. LostFocus

When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:

  1. Enter
  2. GotFocus
  3. LostFocus
  4. Leave
  5. Validating
  6. Validated

If the CausesValidation property is set to false, the Validating and Validated events are suppressed.

If the Cancel property of the CancelEventArgs is set to true in the Validating event delegate, all events that would usually occur after the Validating event are suppressed.

Which means that regardless of how focus is transferred, the new control receives focus before the old one is validated, this allows me to use

if (this.ActiveControl == buttonCancel || this.ActiveControl == buttonReset)
            {
                return;
            }
            // Validation events

which will validate the control in any case that the cancel or reset button are not clicked. The only problem occurs when the user hits the "Esc" key, the normal behaviour when the CancelButton property of the form is set would be to close the window, but I'm guessing, since the "Esc" key does nothing with this setup, the button must not receive focus, something else must be happening.

zachattack05 70 Posting Pro in Training

This is a two part question I guess.

I have a form that allows a user to edit an existing record stored in a SQL database. One of the items the users can edit must have a value when the record is edited using this particular form, but it does accept null values on the server side so validation won't work there. So for this particular form a value must be validated because the SQL server will not throw an exception if it is blank since, in some instances it can be. The value is being evaluated by a custom validation event that I have written (it's nothing fancy, just 3 lines) but I have a problem...

The form contains 3 buttons:

  • Revert - Reverts the record back to the state it was when it was opened in the editor.
  • Cancel - Cancels changes and closes the editor.
  • Save - Saves the data to the server and closes the form.

The main problem I have is that my validation code uses e.Cancel = true; if validation fails which, if I understand correctly, indicates that validation failed and the events following should be canceled, including closing the form, reverting data back to it's original state or even changing to a different control.

That's great and fine, but because of that, the revert and cancel buttons don't work unless the user fixes the validation problem first, which kind of defeats the purpose of a cancel button …

zachattack05 70 Posting Pro in Training

I agree that I shouldn't make assumptions.

I like the idea of disabling the save button if a required field is blank. The label though...I don't know...I always thought that was more of an internet thing, not a Window's forms thing.

I think I'll use the button idea though!

Thanks for the suggestions and feedback!

zachattack05 70 Posting Pro in Training

ddanbe,

True, and I do that already. I'm mostly concerned with someone leaving a required field (usually a textbox) blank.

The numeric filters and even a mask for formatting data correctly is something I already use.

As it is now, the controls that require input (all textboxes at the moment) are highlighted in red if the user clicks the "save" button and they are blank. I'm just not sure if by itself that supplies enough information to the user to know that a value is required and that when they clicked "save" a second ago, nothing was saved, they need to fix the blank box problem before it will be saved.

Is it, or would it be, safe to assume that a "normal" user would:

  • Know that a control that is highlighted needs a value.
  • Know that the "save" operation they expected to occur actually did not occur, and won't occur until they correct any errors.

All of this without explicitly saying "You need to fill x, y and z in first. Oh and by the way, until you do that, nothing is saved."

zachattack05 70 Posting Pro in Training

I'm writing my own validation code for some of my forms and I'm wondering what the best way to indicate that there is a problem is.

Some ideas I've had:

  • Highlight the textboxes, checkboxes or controls in red if they have an error.
  • Put a small icon inside or near the control with the error (the error provider basically)
  • Display a messagebox explaining the error.
  • Use a balloon tooltip on controls with an error.
  • Prevent the user from leaving the control (which is kinda what the binding control does)

There are obvious pros and cons for all of these. My goal is to be as least intrusive as possible and allow the users to work fast, efficiently and be interrupted as little as possible, but at the same time, if there is a problem to let them know what that problem is and how to fix it.

Highlighting the controls with errors is somewhat standard on the web, you don't fill out a box it might change colour or might bold the label next to the control and optionally supply supplemental information on fixing the error. Supplying that extra information wouldn't be as simple with a forms application though.

Using the icons or error provider is good, but to me, it's not all that intuitive. A flashing icon is okay to indicate there is a problem, but it's not very intuitive to know what that problem is, hovering over that icon, that is.

zachattack05 70 Posting Pro in Training

It's appended to the end of the visible text on the screen, if you anchor your label to the left and right side and resize the form the ellipsis appears and disappears. I'm looking for a way to change the "..." ellipsis text to something that is computed based on the visible text on the screen.

zachattack05 70 Posting Pro in Training

I was hoping someone might be kind enough to throw some advice my way on this one.

I am using stored procedures to perform many of the queries for my application. One of the reasons I chose stored procedures was for security.

Because I would like to make the application as dynamic as possible, and "mysterious" to the lowly users (I'll explain in a second) I was wondering if it is possible to bind to permissions from a SQL server?

Here's an example of what I mean.

Assume a user's job when using the application is to just retrieve information on customers to provide technical support to them. This particular user has no permissions to delete customers, or to modify their information, only view it. Given that I would be using stored procedures here, obviously this user would have no permission to execute the Delete or Update stored procedure for that customer. Because the user doesn't have that right, but the person sitting next to them might, I would like to know if there is a way for my application to check if the user has those permissions, and if not, to hide (not even show) the "Edit" or "Delete" buttons instead of showing a "Oops! You can't do that!" message. I'd rather keep it "secret" that the ability even exists. Obviously it doesn't take much thinking to realize it does, but...out of site, out of mind. It might keep "fiddlers" from "fiddling" too much.

zachattack05 70 Posting Pro in Training

Is it possible to transform a label's ellipsis text based on the text displayed on the screen?

For example, if the labels text is constructed from multiple strings and only 2 of the 5 are displayed, can the ellipsis text display "...and 3 others" or something like that?

I have the logic in my head to get the count information, I just need to know how is it possible to get the displayed text value and change the ellipsis text? Or would I need to get the displayed text and remove a certain number of characters and replace the entire string with the displayable data and append my "custom" ellipsis data to it and basically not use the auto ellipsis property?

zachattack05 70 Posting Pro in Training

I'm not sure why, I'm just a nervous person I guess. Just thought there might be an attribute I could use that would remind myself and others. I'll just make a note in the xml documentation :)

zachattack05 70 Posting Pro in Training

I have a method that has 3 overrides, but calling the method outside of a "parent" override (one that accepts no parameters) is useless. Other than a xml comment indicating this, is there an attribute that I can use to mark the method as such?

Some additional information if needed:

The "parent" method accepts no parameters, and just loops through controls on a form to mark them read-only or editable. When that method runs into a panel, or into a groupbox, it calls the appropriate method that begins a new loop through the contents of THAT groupbox or panel using an override method, and if it runs into a panel or groupbox it starts yet another loop until all controls possible are changed...but calling the override methods that accept a groupbox or panel as a parameter would be useless to call if called separately from the "parent" method.

I hope that makes sense...unless someone has a better idea for the concept in general, I'm just looking for a way to prevent myself (or anyone else) from using the overrides, it's already marked private, but other than xml comments, I don't know of a way to make it stand out as a "hey dummy! don't use me out of context!"

zachattack05 70 Posting Pro in Training

Oooooh! Excellent idea! I like it! I don't know why I didn't think of that!

Thanks!

zachattack05 70 Posting Pro in Training

Thanks!

I think I'll stick with what I'm doing now instead, it's not worth a performance hit.

zachattack05 70 Posting Pro in Training

I have 7 different bindingsources on a form right now and I have a "cancel" button to allow a user to reject the changes they made and revert back to the original data in the dataset.

Instead of having my cancel button click event call something like:

private void buttonCancelChanges_Click(object sender, EventArgs e)
        {
            dS_DataSet.RejectChanges();
            BindingSource1.ResetBindings(true);
            BindingSource2.ResetBindings(true);
            BindingSource3.ResetBindings(true);
            BindingSource4.ResetBindings(true);
            BindingSource5.ResetBindings(true);
            BindingSource6.ResetBindings(true);
            BindingSource7.ResetBindings(true);

            ToggleEditMode();
        }

can I just loop through all of the existing binding sources on the form? I can't figure out how to do that if you can.

Any suggestions, or is this really the only way to do it?

zachattack05 70 Posting Pro in Training

Nice!

Thanks! Works perfectly!

zachattack05 70 Posting Pro in Training

If I have a DataRow list and use a foreach statement to create a string containing information in a list format and I want the last item in the list to be preceded by the string " and " how could I accomplish this within the foreach statement or is that not possible?

For example, if my data row contained the numbers between 1 and 10, and my foreach statement extracted the even numbers and put them in a string, I want the output of the string to be:

2, 4, 6, 8 and 10

instead of:

2, 4, 6, 8, 10

Right now I am creating a string list of locations in my locations table, here is my foreach statement as it stands now:

foreach (DataRow xLocation in locationsList.GetLocationsList)
            {
                if (L_String == string.Empty)
                {
                    L_String += xLocation["L_Name"].ToString();
                }
                else
                {
                    L_String += ", " + xLocation["L_Name"].ToString();
                }
            }

the last location should be preceded by the word "and" instead of the "," any ideas?

zachattack05 70 Posting Pro in Training

That's what I figured, but just wanted someone's opinion :)

Thanks!

zachattack05 70 Posting Pro in Training

Simple question: is it a performance issue or bad form to have if statements without a else following?

As an example, an event that is triggered when a listbox selected index changes depends on the selected index value to run, and during the change, the value switches from some integer to a null value then back to an integer. To prevent an exception in the event method because of a null value, is it bad to have the following at the start of the event:

private void listBox_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (someString == null)
            {
                return;
            }
        // Do stuff...
    }

or is it better to do:

private void listBox_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (someString == null)
            {
                return;
            }
        else
            {
                // Do stuff...
            }
    }

Or does it even make a difference?

Personally it's just a formatting issue for me, the else block pushes all of the other code over two indentations causing some of the code that would be in the else block wrap around the screen and I cant stand that the wrapped code doesn't line up with the rest of it.

zachattack05 70 Posting Pro in Training

After reading through as much as I could find on the INotifyPropertyChanged interface, I've kinda determined that the amount of work required to implement it is similar to just creating events on every control to catch changes since the interface requires listing each control anyway (or so it appears).

Thanks for the help, I think I'm going to just set up events, unless anyone cares to share a reason why I am wrong in thinking they are similar. Any advantage to one over the other?

zachattack05 70 Posting Pro in Training

Hmmm...Honestly, I read through that link, and I'm completely lost how that applies. The examples and the description at that link imply that if I am binding to a data source manually I would use that. I'm using the BindingSource control from the toolbox that, evidently already, when bound to a SQL server dataset, implements that interface right? If I do BindingSource.SupportsChangeNotification on my binding source it returns true. However, I see no event that I can subscribe to in the binding source called PropertyChanged or anything close to that, just the standards: AddingNew, BindingComplete, CurrentChanged, CurrentItemChanged, DataError, DataMemeberChanged, DataSourceChanged, ListChanged, PositionChanged.

I tried CurrentItemChanged because the MSDN article on the event states:

The CurrentItemChanged event is raised in response to all of the circumstances that raise the CurrentChanged event. Additionally, CurrentItemChanged is also fired whenever the value of one of the properties of Current is changed.

But nothing happens if I change the text in the textbox of any of the bound controls.

Am I missing something or am I making something simple, complicated?

zachattack05 70 Posting Pro in Training

ChrisHunter,

Yes, there are methods like that for the textboxes and checkboxes...as far as I am aware all of the controls that can be databound have an event handler for something like that. But that is precisely what I am trying to avoid.

If I subscribe all of the controls to an event handler like that, that means that each time the data source changes, not because user edited anything, but because the record moved, the events would "fire" causing unnecessary checks and possibly major performance issues. I am aware of the method of using a bool "flag" so to speak to indicate that the events should or should not fire, but that brings up the second issue. If a control is added or removed from the form in the future or later on in the development stages, the new controls would need to also subscribe to those events causing, in my opinion, more maintenance issues and the increased chance for bugs.

I'd prefer if the dataset, or the binding source or table adapter had a method that could be triggered as soon as data was changed.

I'm sure there is a way to do this, but I can't figure it out.

Is there a way to write custom events?