5 Replies - 703 Views - Last Post: 06 December 2012 - 03:58 PM Rate Topic: -----

#1 Danikashi  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 11-May 12

[WinForms] Button Assignment

Posted 06 December 2012 - 03:18 PM

Good evening. I just started working with Windows Forms and i have stumbled with a problem which i searched and couldn't find anything (maybe my research was just bad) anyways, i want to assign a number (like "1") to a button is there anyways i could do that?
Is This A Good Question/Topic? 0
  • +

Replies To: [WinForms] Button Assignment

#2 Julyuary  Icon User is offline

  • D.I.C Head

Reputation: 38
  • View blog
  • Posts: 106
  • Joined: 20-December 11

Re: [WinForms] Button Assignment

Posted 06 December 2012 - 03:28 PM

Do you mean setting the text on the button? Have you tried the text property?
clickMeButton.Text = someString

You can find more information on the button control and the text property at these links on msdn:
http://msdn.microsof...rms.button.aspx
http://msdn.microsof...y/ms158234.aspx
Was This Post Helpful? 0
  • +
  • -

#3 Danikashi  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 11-May 12

Re: [WinForms] Button Assignment

Posted 06 December 2012 - 03:32 PM

View PostJulyuary, on 06 December 2012 - 03:28 PM, said:

Do you mean setting the text on the button? Have you tried the text property?
clickMeButton.Text = someString

You can find more information on the button control and the text property at these links on msdn:
http://msdn.microsof...rms.button.aspx
http://msdn.microsof...y/ms158234.aspx


No i'm saying like i have a button named "1" and when i press it i want the value "1" to appear in a textbox. Thanks :)
Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4419
  • View blog
  • Posts: 7,687
  • Joined: 08-June 10

Re: [WinForms] Button Assignment

Posted 06 December 2012 - 03:41 PM

I'm guessing that you mean you have a button who's text is "1", and you want that in a text box.

The simple answer is to assign the .Text value of the button to the .Text value of the TextBox in the button's Click event.
Was This Post Helpful? 1
  • +
  • -

#5 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5431
  • View blog
  • Posts: 11,643
  • Joined: 02-June 10

Re: [WinForms] Button Assignment

Posted 06 December 2012 - 03:44 PM

Do you understand that you have to make a method that handles the .Click event of the button?

Do you understand that GUI elements like buttons and textboxes have properties such as .Text that you can set and get?


My standard beginner resources post - Updated DEC 2012

You can try to learn C# by dismantling snippets and googling terms - basically you can take a hit-n-miss, shotgun approach. Or you could just follow a proper training program whether it be a couple intro books, school, on-line course or series of tutorials like the ones we offer. I'll tell you from experience that just fumbling around in the dark and trying to teach yourself with no guidance doesn't work. Its like stumbling across a Harrier Jump Jet and trying to teach yourself how to fly with no background in piloting: You simply lack any groundwork to start from. How can you lay out your own training course if you don't already know the material? Would you go to a university where the teacher says "I don't know any of this but we'll fumble through it together?"

We have a tutorials section and a learning C# series of articles.

First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover. Do a couple hundred on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.

There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

Quote

Where do I start?


You start by learning a coding language FIRST.
Learn to plan before you type.
THEN you start designing software with a purpose.


If this sounds like you

Newbie/Rookie said:

I have a little programming experience but I need to write ...
read this section
Spoiler


Otherwise, you can just jump to the resources here:
Some of the tutorials below are for C# or Java not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.



Resources, references and suggestions for new programmers. - Updated Oct 2012
Spoiler

Was This Post Helpful? 0
  • +
  • -

#6 Danikashi  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 11-May 12

Re: [WinForms] Button Assignment

Posted 06 December 2012 - 03:58 PM

Yeah i know but i am actually taking classes in school about C# and we just started with windows forms i was just trying to get some knowledge so i can start having some "fun" and trying out stuff. Thanks anyways for the stuff you provided me with :)

View PostCurtis Rutland, on 06 December 2012 - 03:41 PM, said:

I'm guessing that you mean you have a button who's text is "1", and you want that in a text box.

The simple answer is to assign the .Text value of the button to the .Text value of the TextBox in the button's Click event.


Will try that. I'll edit if i have any problem with this solution.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1