zachattack05 70 Posting Pro in Training

I'm working on a custom textbox control that can "filter" out inappropriate input.

The filter property can be:

None,
Numerical,
LowerAlpha,
UpperAlpha,
Alpha,
AlphaNumeric,
Symbol

None would function like a normal textbox
Numerical would be any number key (1,2,3...)
LowerAlpha would be any alphabet character as long as it is lower cased
UpperAlpha would be any alphabet character as long as it is upper cased
Alpha is any alphabet character (case is ignored)
AlphaNumeric is any alphabet or number key
Symbol would be any symbol key (;,.'/?*&%!` etc...)

My question is, instead of on the KeyDown event checking which key was pressed by having if/then ad nauseum statements is there a system defined function or something to check these a bit better?

My check to see if a key was an integer is:

if (RestrictBy == Restrictions.Alpha)
                {
                    if (e.KeyCode > Keys.D0 || e.KeyCode < Keys.D9)
                    {
                        if (e.KeyCode > Keys.NumPad0 || e.KeyCode < Keys.NumPad9)
                        {

                        }
                    }
                }

I mean this is just getting out of control! An if statement for determining if a key was a alphabet or symbol key would be huge! There has to be a better way...or am I stuck?

zachattack05 70 Posting Pro in Training

Hidden field?

This is a windows app not a web app sorry I should have clarified.

zachattack05 70 Posting Pro in Training

Can this be done?

I know you can databind to form controls, but what about object properties?

For example, I have a form that has two functions, to edit a record and to create a new record, but the problem is that in order to create a new record you need a reference to another record (FK) but the user shouldn't have to "pick" that in the editor, instead they have already done that by opening the editor within a certain record already. I just pass the FK to the editor as a constructor parameter. I need to databind to that so when the user saves the record the FK is already there.

I have it working now by binding to a label, but when I set the label property to "Visible = false" it doesn't work and the binding fails.

I don't really want the user to have to stare at an irrelevant (to them) number that references the FK.

Any ideas?

zachattack05 70 Posting Pro in Training

Hmmmm interesting.

Thanks!

zachattack05 70 Posting Pro in Training

Momerath,

Do you ever keep the default event handler names if you do things alphabetically? Like: "buttonApplyFilter_Click" or do you change the names?

I know it's a personal preference, but I'm curious, that's why I asked.

zachattack05 70 Posting Pro in Training

Momerath,

How do you order methods in your regions?

zachattack05 70 Posting Pro in Training

Why stop using regions? Is there something bad about them? I like it because I can find things faster (or it seems like it anyway)

zachattack05 70 Posting Pro in Training

How do you personally organize your methods, event handlers (kinda the same), properties etc... in your classes?

I've been grouping things by type using regions and then alphabetizing them within the regions, but I was just wondering what other people do if there is a standard?

zachattack05 70 Posting Pro in Training

I have an issue where two text labels are on the same horizontal line on a form.
The label to the left expands to the right and down and is anchored to the bottom left of the form.
The label on the right is anchored to the bottom right of the form.

Both labels hold an address, one is a mailing address, the other is a physical address.

Both should have left aligned text, but the problem is that since the labels are autosized to fit their content, the label on the right always runs off the screen and when the form is resized, because of the anchor, nothing changes.

Is there a way to do something like this: (ASCII art is hard!)

------------------------------------------------------------------------
|                                                                       |
|  123 Any Street                                 2039 Market Street    |
|  Cincinnati, OH 45168                           Cincinnati, OH 45168  |
|                                                                       |
------------------------------------------------------------------------

instead of:

------------------------------------------------------------------------
|                                                                       |
|  123 Any Street                                       2039 Market Stre|
|  Cincinnati, OH 45168                                 Cincinnati, OH 4|
|                                                                       |
------------------------------------------------------------------------

I'd really appreciate any advice!

zachattack05 70 Posting Pro in Training

The problem with that though, is the scroll bar is always visible, even if the textbox is blank, it's just disabled.

But I'll look at that one too. Thanks!

You guys are always so helpful :)

zachattack05 70 Posting Pro in Training

Awesome! I'll give it a shot. Thanks! :)

zachattack05 70 Posting Pro in Training

Hmmm the textbox has a top, left and right anchor to the form, so it's width grows and shrinks with the form size, but not the height.

I considered the number of characters, but if someone has a higher dpi screen resolution that could change, could it not? I'm not sure about Nick's idea, I'll have to look at that one too...hmmm

zachattack05 70 Posting Pro in Training

Any idea how to determine if the vertical scroll bar is active in a multiline textbox?

Active as in, the user can click the arrows and the text is long enough to scroll. Similiar to being enabled/disabled?

I'm trying to have a mouse event so when the user moves their mouse over a specific text box and if the scroll bar is active, after a second or so, a small transparent image appears in the bottom right side of the textbox indicating if the user clicks that image the text in the box will open in a larger window for them to view and resize instead of scrolling.

zachattack05 70 Posting Pro in Training

Ooooh!

I like that!

zachattack05 70 Posting Pro in Training

It's a personal hang-up. Tag is one of those properties I never use on a object. I just need to get over it I think.

I have the same hangup with using "reflection" for anything. For some reason I keep thinking that using reflection is a very bad idea, and if your only solution is to use that, you shouldn't be doing what your doing.

Meh, now that I think of it, no wonder my co-workers look at me like I'm crazy most of the time!

I am just a stickler for efficiency and standards. My mentality is "Just because tag and reflection are there, doesn't mean you should use it."

Oh well, I'll just go with the tag. Thanks! You always seem to be so helpful! Too bad you can't nominate users as MVPs or something :)

zachattack05 70 Posting Pro in Training

Thanks!

zachattack05 70 Posting Pro in Training

Momerath,

Yeah, my method uses the same yours does in your example. I think I'm just spoiled with the IDE and for some reason don't think outside the box now when it comes to controls on a form.

I'm going to throw this out there and please, point and laugh if it's a bad idea... but is it possible that while a form is being layed-out, to add a reference to the radio buttons in a specific container (in this case a tab control page) to a dictionary object, or some type of array? With the assumption that the dictionary/array would ALWAYS add the references in the same order?

Just a thought. Otherwise I think I'll use the tag control, though I don't really like it much.

zachattack05 70 Posting Pro in Training

Do you happen to know what OS .Net 4 is available on?

zachattack05 70 Posting Pro in Training

I've done some research and it appears that Windows 7 is about tied with Windows XP users as far as current popularity (Vista seems to be a flop).

My MSDN subscription includes access to multiple builds of various operating systems for "free" for development purposes. If my project is developed, tested and built on Windows 7, assuming that VS is installed on Windows 7 and the entire project is developed in Windows 7, would that, for any reason, exclude Vista, XP (and for fun) 98 users? I know that most software can be run on newer versions of OS, but older, not usually...

I've not played with setup projects much (ok not at all), but should I be worried that I might be excluding certain OS from running my application simply because of the one I'm developing on?

zachattack05 70 Posting Pro in Training

Doesn't appear that a radio button has a value property other than true/false so I was hoping someone could help me out with this one.

I'm writing a method applied to the "CheckedChanged" event. The method is applied to all of the radio buttons, so it always triggers regardless of what button is checked.

The issue is, each button applies a specific filter to the data displayed on the form and I am having problems determining which filter to apply because determining which radiobutton (of the 3) is actually in the checked state.

I know I could always use the name of the checkbox or the text associated with it, but those are rather arbitrary values in the whole scheme of things (in other words, the control names or text values could change before the project is complete and the change might be missed in the code) so I was hoping I could apply a static (or close to static) value to each radio button besides using the name, text or tag property. Any suggestions?

zachattack05 70 Posting Pro in Training

No that's not what I mean. It's a good idea to protect your projects the best you can.

I think I might just ask people to test it like you said and see what the outcome is.

zachattack05 70 Posting Pro in Training

While I am of course concerned with people ripping off the product and I appreciate the suggestions on piracy protection, I'm more concerned with:

1) finding testers that are relevant.
2) protecting myself if my application crashes and the tester insists that damage was caused by my application.
3) getting usable feedback from the testers in a easy and effective way.

I know that people will try to rip things off, it's the name of the game these days. The internet is chock full of pirated software, and no matter how big or small your company is or how popular or unpopular your software is, people will steal it. There's really nothing I can do about that. As soon as I come up with a way to protect my application from it, someone will break it. It's an endless cycle. Even Bill Gates, when asked what he thought about all the people pirating Windows, he said "well at least they are stealing my software and not someone elses!"

zachattack05 70 Posting Pro in Training

Not a bad idea. Only problem is that my friends/family might be reserved, or bias when providing feedback to me.

zachattack05 70 Posting Pro in Training

Thanks! I'll check it out!

zachattack05 70 Posting Pro in Training

I have a databound listbox. The data source also has a bit field associated with it, I would like for listbox items that have a bit field value of 1 (true) to show bold and the rest to remain non-bold. Any idea how this can be done or is it not possible?

Also, as a side question, the image attached...its from VS, is there a way to replicate that control? The actual image control, that has tabs and a pin button, close button etc, that lists the controls and data sources? It looks like a tab control with the tabs at the bottom, but I don't know how to replicate that pin button...any ideas?

zachattack05 70 Posting Pro in Training

The project I have been working on and seeking advice on from this forum for over a year is approaching it's final steps. All that really remains is arranging the controls on the forms into a layout that is both functional and "pretty" (and getting a nice bottle of champagne of course).

Once that step is done I'll need to test my application, preferably with those who know a little about the goals of it and can provide constructive feedback.

My question is 3 fold:

1) How can I find such beta testers? (preferably for free)
2) Before providing copies of the solution to the testers, are there any suggestions on how to protect all of my hard work besides obfuscating the code, which only protects me from hackers/programmers (and even then only marginally).
3) What kind of protections should I have in place to prevent the concept and goals of my solution from falling into the hands of my future competitors? And what, if any, liability for data loss, hardware failure etc...would not be covered with a standard EULA that the testers would agree to?

I know #3 is kind of a legal question and trust me I plan on consulting with counsel first, but would prefer to get some feedback from those who might know before spending $250/hr for someone to stare at me and say "ummm...I can turn my computer on and off? I can show you if you want?"

zachattack05 70 Posting Pro in Training

Not a bad idea!
I'll give that a go!

zachattack05 70 Posting Pro in Training

Not sure how to do this one...

I have a combobox that is bound to a datasource and I would like to add a entry to the tail end of the combobox that says "<Add New Item>" which, when clicked opens a wizard that will allow the user to add a new record to the underlying datasource.

I attached an image of what I'm talking about.

When I try to edit the Items property, I get an error saying "Cannot modify the Items collection when the DataSource property is set."

Unfortunately adding the "<Add New Item>" to the underlying datasource isn't really an option.

The other issue is, of course, that because it is in a databound object, when the underlying data source is updated, the text "<Add New Item>" should not be inserted into the underlying datasource.

Any suggestions would be welcome.

zachattack05 70 Posting Pro in Training

I actually have solved this issue.

Instead of adding a .mdf file to my project, I simply installed a new instance of SQL Server 2008 R2 Express on my development system. Configured it how I wanted, copied my database file I made, along with the log file to the SQL Data folder (where it will be installed when my application is installed) opened SSMS, logged into the new instance I created, "attached" my database, scripted the change and saved it so I can attach it when I'm installing my application.

Now when I develop my UX, all I need to do is create a "dataset" or whatever method I like, and get the data from my instance. This works great, the database starts up with the SQL service on system boot (even without a user logging in) and is fully accessible! All I need to do is "search" for the SQL instance over a network on first run, and when I find my instance, modify my connection strings in the dataset(s) and then use it. If I can't find the instance, the user can provide the server's name.

Piece of cake!

Only issue now is, how to create (if needed) Windows users so that other users can access the database with integrated security...I know it's possible, I just need to find out how :)

Best of all! The application will know each time it starts if it is a server or client! All it needs …

zachattack05 70 Posting Pro in Training

you can store the data in a column with the data type set to varbinary(max) which holds a varying length binary data object up to 2 GB in size.

Thines01 has a point though, depending on the server type (express versions etc...), the purpose of the server (just hosting files, or what?) you might run into issues. Database file size is nothing to ignore, just because you can hold 2GB of data in a column, doesn't mean it's the best way to do it.

You might want to look into enabling and using Filestream on your sql server instead.

From MSDN:

In SQL Server, BLOBs can be standard varbinary(max) data that stores the data in tables, or FILESTREAM varbinary(max) objects that store the data in the file system. The size and use of the data determines whether you should use database storage or file system storage. If the following conditions are true, you should consider using FILESTREAM:

Objects that are being stored are, on average, larger than 1 MB.

Fast read access is important.

You are developing applications that use a middle tier for application logic.

For smaller objects, storing varbinary(max) BLOBs in the database often provides better streaming performance.

zachattack05 70 Posting Pro in Training

Clever.

I like it!

zachattack05 70 Posting Pro in Training

I'm looking for suggestions on the best, and easiest way to install a Windows OS (in this case, XP, Vista and 7) on a hard drive, install my app., test it, make changes and then reinstall my app with a clean copy of the OS?

Instead of sitting around going through the setup process 100000 times, is there an easier way? Partition a drive in half maybe and use one for booting and another to just hold a copy of a fresh install and then just clear one and copy over again?

Any suggestions or real-life scenarios/solutions?

zachattack05 70 Posting Pro in Training

Bleh! I was hoping for a different answer. :(

Stored procedures are new to me and to be honest kind of scare me only because they rely on me not making a mistake. With relationships, I only need to use one delete command and boom, the rest is done and no human error is involved.

Thanks for the articles! I'll investigate them a bit closer.

zachattack05 70 Posting Pro in Training

If I have SQL authentication enabled, and a user (UserA) on a database has permission to delete rows on TableA, but not TableB, and there is a relationship between TableA and TableB, can UserA successfully delete a record on TableA and have the changes (based on relationships set up) cascade across tables UserA has no permission on or does the user have to have permissions on all related tables? (wow that was a run-on sentence...my teachers would be so proud!)

Does that question make sense? I imagine the changes WOULD cascade, otherwise what's the point?

zachattack05 70 Posting Pro in Training

I would imagine probably by transferring an image from the camera to the other side via sockets?

If that's the way to do it, it's not a simple process...you can start by reading about sockets here though. But I'm really not 100% sure, this would be the route I would take though.

zachattack05 70 Posting Pro in Training

OK so I have a decent database that I have set up with all the correct tables and relationships, but now I have another issue, and that is distributing it. I don't know how to achieve what I am after.

I know how to install SQL Server Express during my setup, or shortly after through the command prompt and in silent mode. That's not my issue. The issue is, there needs to be a "Server" and a "Client" version of the application (preferably the same, with just a customizable connection string).

The problem I am having is how to import the database I made into my project so that this is a possibility.

I have no problems importing the database file into the project so that I can use the data source in the project, but the problem is:

1. The database only "mounts" when the application is running
2. The connection string is stored in the applications settings file, and is marked as application scope (which is a pain to edit, but yes, I know it's possible)

And there are some unknowns that I was hoping someone might be able to help me with:

1. If the application mounts the database on a sql instance that is discoverable and accepts remote connections, will that database be accessable on the network? If not, how can I make it accessable?
2. Is there a way to install a new instance of SQL server …

zachattack05 70 Posting Pro in Training

I have no idea. Maybe it doesn't come with Windows XP.

Hmmm...I never thought about that...

zachattack05 70 Posting Pro in Training

I use the built in Settings class. If you want control, it does allow you to specify your own settings file to load/save.

Do you ever have problems with your settings being overwritten when you release a new version? That's what I'm always worried about.

zachattack05 70 Posting Pro in Training

So I'm curious, when you need to store user settings or application settings what method do you normally use?

I have been using a class and just serializing it to a file. But there is also the "settings" in the application's properties folder. Does anyone ever use that? Any pros/cons to either method? Suggestions?

I always used a class because I can store it however I want, where ever I want and feel like I have a bit more control.

zachattack05 70 Posting Pro in Training

You only need to license it if you are going to distribute it (which is what it says).

True, just wanted to make sure. :)

Edit: Why would anyone need to license it then? C# is a managed language and needs .NET to operate. Unless I missed something, .NET only installs on Windows, and if Windows comes with the font...who would ever need to license it?

zachattack05 70 Posting Pro in Training

Here's the entire article from the guide:

Users interact with text more than with any other element in Microsoft® Windows®. Segoe UI (pronounced "SEE-go") is the Windows system font. The standard font size has been increased to 9 point.

(Illistration of Segoe UI font)
The Segoe UI font.

Segoe UI and Segoe are not the same font. Segoe UI is the Windows font intended for user interface text strings. Segoe is a branding font used by Microsoft and partners to produce material for print and advertising.

Segoe UI is an approachable, open, and friendly typeface, and as a result has better readability than Tahoma, Microsoft Sans Serif, and Arial. It has the characteristics of a humanist sans serif: the varying widths of its capitals (narrow E and S, for instance, compared with Helvetica, where the widths are more alike, fairly wide); the stress and letterforms of its lowercase; and its true italic (rather than an "oblique" or slanted roman, like many industrial-looking sans serifs). The typeface is meant to give the same visual effect on screen and in print. It was designed to be a humanist sans serif with no strong character or distracting quirkiness.

Segoe UI is optimized for ClearType, which is on by default in Windows. With ClearType enabled, Segoe UI is an elegant, readable font. Without ClearType enabled, Segoe UI is only marginally acceptable. This factor determines when you should use Segoe UI.

Segoe UI includes Latin, Greek, Cyrillic, and Arabic characters. There are new …

zachattack05 70 Posting Pro in Training

So I'm plugging away at my database design and get to a point where I need to work on the UX (or UI for you old[er] peeps). I have a guide from Microsoft that I refer to very often called the UX Guide.

I have all of my forms setup to use the "Segoe UI" font because in the UX Guide it states (emphasis added by me):

Segoe UI is optimized for ClearType, which is on by default in Windows. With ClearType enabled, Segoe UI is an elegant, readable font. Without ClearType enabled, Segoe UI is only marginally acceptable. This factor determines when you should use Segoe UI.

Since Microsoft has already spent millions of dollars on user research and what works best, why should I doubt it?

So anyway, I'm going along and need to reference something else in the UX Guide, and as I'm looking, I stop in the same section the quote above is from and see this:

To license Segoe UI and other Microsoft fonts for distribution with a Windows-based program, contact Ascender.

So....is this font, even though it is included in the menu to select a font, off limits without a license?

I mean...If I have the font installed on my development machine, and I indicate to use that font, but I don't include the font for distribution on my CD (or whatever) and an end user installs my application and already has that font on their system....is that a …

zachattack05 70 Posting Pro in Training

Awesome! That's exactly what I was looking for!
Thanks!

zachattack05 70 Posting Pro in Training

Oh, my bad. Like I said, I've never used Udp.

On a local/loopback connection you said it's working...the only thing I can think of is a router, either at the server end or the client end is dropping the data, or doesn't know where to route it so it drops it.

You said there are no firewalls blocking it, so maybe it's just a routing issue? I'm grasping here...no real idea, but throwing out suggestions.

Sorry I'm not much help, maybe someone else might be.

Have you tried using a program that you haven't written yourself that uses Udp to see if it works? Can the client and server "ping" each other with the command line console?

Good luck :)

zachattack05 70 Posting Pro in Training

I've never used Udp, but I still think you need to have your server "listen" for connections.

Maybe this will help: Socket.Listen Method (MSDN)

zachattack05 70 Posting Pro in Training

BinaryFormatter.Serialize writes to a stream, so if you want to serialize an object to a byte array, using a MemoryStream is the simplest way to go.

I'm not sure what "write the array to a MemoryStream first" is intended to accomplish; you can create an expandable MemoryStream without creating a byte array first.

What I meant by that was, I started with a byte array to begin with. But since the BinaryFormatter requires a stream, I have to copy the array to the stream then serialize the stream.

When things come in over a network on a socket they are transferred as a byte array and if I need to serialize that array that I received into whatever, a file, for example, I need to copy that array to a memory stream and then serialize the memory stream...seems redundant to me. I wanted to know if there was a way to serialize an array of bytes, as in "byte[]."

I was always under the impression that a memory stream is just a glorified byte array that can expand and contract depending on how you use it, where as a byte array (byte[]) you can't do that, you need to create a new one with the new size and then copy whatever you need to the new one.

I guess what I was asking is, can I take a byte or an array of bytes in the form of byte[] and either …

zachattack05 70 Posting Pro in Training

Are you using synchronous or asynchronous sockets?

Either way, if you have a socket and have no mechanism to loop (with a timer or something else) a read on the socket, the server and client will connect and basically sit there without listening to each other. You can talk all you want on one socket and send 10000 messages, but if the other end doesnt "read" the socket, it just sits there.

GPXtC02 commented: helpful +2
zachattack05 70 Posting Pro in Training

Hey that's actually not a bad idea!
Question though: The field indicating the source table, would that only be present in Table C, or also in the source tables?

I thought about doing that as well, but dumped the idea because I thought it was a waste of space and a source of confusion to have data that really doesn't mean anything.

zachattack05 70 Posting Pro in Training

Here's a drawing that might explain what I'm after a bit better:

zachattack05 70 Posting Pro in Training

Let me attempt to clarify:

Imagine a database that holds medical records such as patient information, test results, names and tests offered at various laboratories, names and services offered by various physicians etc...

The user of the program maintains these lists themselves and also performs some (but not all) of the services in house.

Now:

Table A - A complete list of laboratory services offered by all laboratories, this includes test codes, costs and relationships to a laboratory table to identify the laboratory itself.

Table B - A complete list of physician services offered by all physicians, this includes billing and services codes, costs, and relationships to a physician table to identify the physician office itself.

Table C - A list of services available only at the software user's location. In order to populate this table, the user will need to enter what services they offer at their location.

Some services from Table A are independent of a service from Table B and some are not. For example: a laboratory may perform a test, and depending on the outcome of that test will either report the result directly to the patient or to a Physician for review/consideration. The review of a result from a lab is a service that a physician can offer. But, they are independent of each other.

When completing a row in Table C, the user would need to indicate (in some fashion) a relationship that is like this: