Better performance

Puiu

Regular
Joined
Oct 6, 2004
Messages
90
1. What would be better to use: a form with a tab control that has around 20-25 tabs or a mdi form with 20-25 forms ? The user doesn’t see the tab pages, he moves between them using linkbuttons.

2. I have multiple textboxes where I want the user to insert only numbers. So far I thought about 2 ways to do this: I either let them write anything in the textbox and then check each character to see if it’s a number, or I can create a sub that handles the keypress for the textboxes
 
In answer to 1. I'm not entirely sure which of the solutions you suggested would be better. You say the user doesn't see the tab pages, yet as far as i'm aware using the default TabControl you can't hide the tabs. Performance-wise alot would depend on how many controls you have on each of the tab pages. The way I have handled this in the past is to 'create' and 'destroy' the pages on the fly as the user switches between them. Here's an example of what I mean..
C#:
private void GotoPage(int pageNum)
{
        myPagePanel.Controls.Clear();

	switch(pageNum)
	{
		case 1:
			// add controls for page 1
			break;
		case 2:
			// add controls for page 2
			break;
	}
}
I'm not convinced thats the best way of doing it, but its one I've used in the past.

In answer to 2. I would add code to the Validating event of the textbox checking if the contents is numeric. This way the user can input anything but if its not a number you can either empty the box and make them do it again, or use the ErrorProvider control to inform the user that the value in invalid (or one of any number of things). In terms of checking if its numeric if your using .Net 2.0 you can use int.TryParse, but if your using .Net 1.1 then you will have to error trap int.Parse.
 
#2. If you don't need to use a textbox, the NumericUpDown control would be the best tool. It limits user entry to only numbers and has buttons for incrementing/decrementing a number. Offhand, I'm not sure if you can remove the buttons.
 
Cags:
It' s a custom TabControl that can hide the tabs...however there are over 20 tabs so i was wondering if it will not need to much RAM...
 
Alot depends on how the custom tab control handles the controls, if it uses a system similar to the one I described then RAM usage would be low, but I find this unlikely. It's most likely that all the controls are loaded with the tab control and are controlled by changing the Visible property of the tab pages. If this is the case then the chances are it would use a lot of memory if you have a lot of controls. The only real advice is to try it with the amount of controls you envisage using and see how much RAM it uses.
 
Back
Top