Please Reply about coding vs designer/wizard practise

Status
Not open for further replies.

AnjaliArora

New member
Joined
Jun 23, 2006
Messages
3
Programming Experience
Beginner
Hi Friends

I m new in this field.Could you please clear some of my doubts.

1. I heard it is better to use coing mode rather than design mode to create or insert some contoles LIKE:

a) creating connection string, data adapter , dataset through coding instead of wizard.

b)creating insatance of tool tip

like ttp1 as tooltip

n then use it on every control, on which tooltip to provide rather than draging tool tip controle from toolbox n setting tooltip at design time.

Same with error provider, status bar etc.???

Hope I were able to make myself clear.

Please someone reply me why coing should be prefered, if so. When such a easy way to use these functionalities has been provided
does it makes any effect over speed of application??

2.how we can clear all the controles' value by smallest coding LIKE ()

one common way: textbox1.text=""
textbox2.text="" .......... same for all

any other way

( and if u could please provide the best coing approch for al this, as I am new I wanna start with right thing.)

Thanks of lot if someone would help.
 
kulrom said:
Hello,
1st off i must say that you are approving your statement giving not adequate examples that are not related with the current question and that is not correct cuz it is confusing the people.
If TypeOf tbx is Object then MessageBox.Show(///}
This will work just cuz VB6 TypeOf function is created to accept a parameter of Type OBJECT. That's why you will get the expected result that doesn't prove anything.

The cod ein my example says just as you have quoted:

If TypeOf <variable> Is <static type> Then ..


TypeOf is not a function, it is a VB.NET keyword for an operator just like Is, IsNot, AndAlso, OrElse, AddressOf, +, * etc.
If it were a function, VB would insist we say TypeOf(x). If we try to type that, it changes to TypeOf (x) indicating that typeof is not a function. (The space is significant, between typeof and (X) :) )

for more information see here:
http://msdn2.microsoft.com/en-us/library/0ec5kw18.aspx



In my opinion: you will want to use TypeOf if you want to also match controls that are inherited from the base control. while, you will want to use GetType when you want to know that it was specifically that type of control that is case here (we are looking for control's type) ..right?

Correct. My post says this..

GetType will tell you if an object is of a certain type, whereas TypeOf will tell you if an object is type compatible with what you specified..

In my example, i use TypeOf because im looking for TextBoxBase - the parent control of serveral types of textbox.


You are now saying what I, personally, believe you should have said in the beginning - rather than your blanket "use GetType() instead)

But also notice that there is VB.NET way to accomplish the same. Next time i will explain to you.

Indeed.. but please dont be thinking that TypeOf is VB6 legacy and there is a VB.NET way to do it.. - it's as much .NET as anything else. (it's present in c#, so it cannot be VB6 legacy)
Remove the reference to Microsoft.VisualBasic from any one of your projects, and you will see that, of the many things that become unavailable.. TypeOf is NOT one of them.


My post went a little further to qualify yours (hence the reason i said i was qualifying yours) with regards to TypeOf and GetType - you just said to exclusively use GetType, but TypeOf is valid and necessary in certain contexts - one of which I presented an example of.

Additionally, the messagebox messages were important (you trimmed them out when quoting me) because they made the code self documenting i highlighting the point i was trying to make..

I'm not being serious, I'm just being correct. Many times i have seen here a correction to my suggestions or a better way to do something i've advised and I have accepted the correction and been thankful for it - its important to me that when giving advice to others, that i'm not limiting them or giving them partial or incorrect information. Others are motivated to talk less than me and that's fine - but they should be aware that I may come along and rasie a little extra discussion around their answer, should I choose to (for everyone's benefit, inclding my own knowledge) :)
 
Ok, there is only one thing that i agree with ...it is .NET stuff but inherited from VB6 and as you said 1st presented in C#. But i was wondering why you didn't answer my last question ... how you came with this? how you bring it related with the original question? Nevermind, you don't have to answer it /// moreover, from now i will ignore your posts just cuz of this statement: Many times i have seen here a correction to my suggestions. That's how i will let the ppl to feel benefit of your replies.

Regards ;)
 
kulrom said:
I am not sure why you mention textBoxBase at all. TextBox is based on the TextBoxBase class which is based on the Control class. So how it is related with the problem we solve here? Please be gentle with your answer ... lol

Perhaps, i should have merged the two posts together - you'll notice they were written immediately after each other, in where i explain why im looking for a textboxbase - i want to clear all text boxes on the form.

I've actually just reviewed the entire thread and I can see it was skewed by Craig's initial post...

The OP asked how to clear all Controls.. he inferred textboxes but actually asked for controls. in this case our answer should have been:

VB.NET:
       Private Sub ClearTextBoxes(ByVal ControlList As ControlCollection)
            For Each Ctrl As Control In ControlList
                Ctrl.Text = ""
                If Ctrl.HasChildren Then
                    ClearTextBoxes(Ctrl.Controls)
                End If
            Next
        End Sub

which will, of course, clear all text on the form, labels, the lot.. ang.. all gone. THere was an assumption that the OP was talking exclusively about textboxes, but we may never know as this angle wasnt followed up.

The OP returneed to say he was having some difficuly using TG's solution.. I guess i'll answer that now;

AnjaliArora:

To clear all textboxes on your form, paste TG's code in to your form's code somewhere down the bottom so it becomes its own sub

anywhere else in any other sub on your form, call this:

ClearTextBoxes(Me.Controls)



Me.Controls is a reference to the Controls collection of the form.. it will be searched and textboxes will be cleared, groupboxes and suchlike will be iterated into.
 
Ok dude ... it seems like you waitied for something like this to bring atttention to yourself ...ok then you succeed. You alarmed all the community of moderators telling own frustrations but anyway based on my good will I will open the thread and put you in my ignore list.
Btw, the fact that you were (well maybe you were) moderator to other forums it doesn't mean that you can do anything you like here ... including the alarming cominity just cuz of your hurted ego.

Regards ;)
 
I'm closing this thread, it's out of hand. The main inquiry about 'coding vs designer/wizard practise' was just about ignored in every post. The question about clearing text controls should have been asking in it's own thread. If somebody wants to discuss GetType/TypeOf they may very well start their own thread about this issue.
 
No no ... do not close the thread ... i just opened it ... leave it as it is.
As i said i am already out of this and he wanted the thread to be opened so now it is. Please ignore this if you don't want to participate in coding vs designer ... blah blah.
Thanks for understanding :)
 

Attachments

  • www.jpg
    www.jpg
    27.1 KB · Views: 39
Status
Not open for further replies.
Back
Top