Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Tips for the day ..

combobox

  • Please log in to reply
4 replies to this topic

#1 gokuajmes

gokuajmes

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 483 posts

Posted 06 April 2010 - 08:31 AM

Hi ,
it has been almost a week since my last tutorial ,my fingers were all crammed up writing those length tutorial and testing the code for bugs ,Practicability ..what not !Instead thought of writing short burst of useful code that every programmer would like to know.something like ...
how do i change the button text through program? can i move the form behind another? .The post will be updated each day ,hence the members could benefit from one single post rather than searching loads of data.

Tip of the day : April 6th 2010

Q ) How do i get the selected item from the comboBox control ?
ans : This is the foremost functionality any windows or Asp.net application programmer would like to know. As always there are more than 1 ways to do things when it comes to programming ,& this is one of them.

Vb.Net:
ComboBox1.[COLOR=DeepSkyBlue]SelectedItem[/COLOR]
try putting that to a live example with a messagebox and see for yourself

C#
comboBox1.[COLOR=MediumTurquoise]SelectedItem.ToString()[/COLOR]
yes the code is bit different because C# is strongly typed language and programmer has to explicitly specify that the selectedItem is a string.


Tip of the day : April 8th 2010
you might be wondering why 7th is not in the list , the post got approved late that was the reason ! any way let us learn something today

Q)How do set the Text in the textbox on a Button click?
ans: This is like such a common functionality someone would like to provide.Used in many,many applications like a sales calculator where the cashier clicks the button to get the total in a textbox , a simple calculator perhaps needs this functionality too .so lets see how to set the text programmatic ally.

First drag and drop a textbox , button onto a windows form in windows forms application.Donot change any properties .

Double click the button on the form .You will be shown the code window with a event handler for the button1_click write this code inside the event handler

C#
[COLOR=MediumTurquoise]this.TextBox1.Text[/COLOR] = "Hello World !" ;

VB.NET
[COLOR=MediumTurquoise]Me.TextBox1.Text[/COLOR] = "Hello World !" 

Now run the form by hitting the F5 key . Click the button.
The text of the textbox is changed to "Hello World!" now.that is it for today guys

Edited by gokuajmes, 08 April 2010 - 06:43 AM.

  • 0

#2 terroare

terroare

    CC Newcomer

  • Member
  • PipPip
  • 15 posts
  • Programming Language:C#

Posted 08 May 2010 - 07:29 AM

I have a tip too :D
It's a performance tip ;)

for(int i = 0; i < array.length; i++)

at first it seams to be an innocent loop, look closer, let's say that the length of the array is 1000, and every time that nasty length method will be called.
int length = array.length;
for(int i = 0; i < length; i++)
My tip - don't use methods in loops with big cycles.
  • 0

#3 gokuajmes

gokuajmes

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 483 posts

Posted 14 May 2010 - 08:57 PM

Really cool tip man . I always recommend people to avoid methods inside a Loop or Check condition in a Loop .
But array.Length is a property man & not a method :D

Edited by gokuajmes, 14 May 2010 - 08:58 PM.
included line 2

  • 0

#4 gokuajmes

gokuajmes

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 483 posts

Posted 14 May 2010 - 09:00 PM

It has been long since i posted in this thread , so let me continue with the posting again
  • 0

#5 gokuajmes

gokuajmes

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 483 posts

Posted 25 May 2010 - 09:07 AM

again i am busy constructing my site ,please do bear with me .I am kind of procrastinating things i think :D
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download