• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Visual Studio Variables

LBJuice

n00b
Joined
Jan 23, 2005
Messages
27
I'm building an application in C# in Visual Studio 2005. I have a form that has around 1500 check boxes. is there a way to have variables generated based on the check box text? Because I don't feel like writing that all out by hand. Also is there a more efficient way to make a form application such as writing it out in the designer? I'm a perfectionist, and I feel like the code generated is messy and uses a log of unneeded expressions, it's killing me.

Lastly is there any stand way of write variables like I know text boxes people usually call it txtfName... or lstbox etc but if I have a check box with long value, how do pros do it?
 
Most of your questions are kind of moot, since your UI is so fundamentally broken. I'd never use an application that had more than 1500 static check boxes in one form. At least, I'd never use it a second time!

The WinForm designer gives you a choice. You can use the designer and therefore use the code it produces for you, or you can not use the designer and use your own code to create, position, and setup your controls.

I strongly doubt you need 1500 controls on your form. If you really do, then coding them up with the designer is probably a very poor approach; you should be using a control that generates the controls and lays them out automatically from data -- that is, from a list of the names and controls that need to be created. With your approach, any change to the list is going to require code changes. If you dynamically create the controls, you can make things more orderly, automatically!, and have much less work to do when one of the 1500 controls needs to change, when some get deleted, or when some get added.

Coding standards are arbitrary. Pick a name you like and stick with it. Me, I use mostly C++-style conventions even when coding C#; and I use Hungarian instead of the .NET CamelCasing, FXCop style. I'd name the control objects "m_chkSomethingMemorable". You can invent your own style if the organization you're working at doesn't already have one; you can search the web for styles and choose one of those if you'd like. You might want to download FXCop and try it; running it and reading its docs will show you what the CLR team itself tries to use.
 
Ok, I'll clarify as to not come off like a complete ass making 1500 check boxes. This application will be used for generating reports. Check boxes are really the best bet because on like 90% of the fields there could be instances where there could be 2 values, so its necessary. I looked around the internet I cannot find any controls that lay them out for you besides the flowlayoutcontainer which I'm using. I would in retrospect use the list checkboxes tool except i'm almost done.

is there some other way for WinForm to lay out the form with the data you supply it? please let me know
 
I can't guess what it is you're doing from your vague description. I'm not trying to bust balls--computers are very exacting machines, and to come up with the right solutions, you need to be very precise about specifying your problem. But I'm sure you don't need 1500 controls.

Have you timed WinForms while creating and setting 1500 controls, by the way? What about destroying them? Have you measured how much memory WinForms will use?

Does your "almost done" estimate include fixing the usability and efficiency problems you've got?

Why not use a list view control in report mode? You can show "Yes" or "No", or whatever words you use for your two values. Or you can even show icons, drawing an empty square or a marked square, just like a check box. You can efficiently manage as many columns and rows as you'd like.

When you say "generating reports", to me it means something printed and not a screen. Are you printing data, or just showing it to the screen? Or both?

I don't know what you mean by "another way" to lay out a form. Like I said, you either draw the form in the designer and let the designer's code tell WinForms what to do, or you implement that code yourself. It's not hard to write code to lay out controls; the difficulty you'll face will be directly proportional to the complexity of the layout you need.

What is a "flowlayoutcontainer"? Do you actually mean a FlowLayoutPanel?
 
Back
Top