(WP)Bermain dengan Button,Textbox,CheckBox,RadioButton

Salam Termanis dari penulis, kali ini kita akan bermain dengan Button,textbox,checkbo,radiobutton, disini saya menggunakan source pemograman C#, teman teman jangan terlalu bingung, karena C# sama seperti C++ dan Java, karena C# merupakan perkembangan dari kedua bahasa tersebut. langsung kita mulai..

1. Create Project dengan nama Belajar

2. Pilih dengan menggunakan bahasa C#

3. Buat Tampilan User interface seperti di bawah ini

2

4. Isi x:Name(id atau deklarasi variabel)

 RadioButton=  <RadioButton x:Name="Radio1" Content="RadioButton" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1"/>


CheckBox =   <CheckBox x:Name="Checkbox1" Content="CheckBox" HorizontalAlignment="Left" Margin="0,66,0,0" VerticalAlignment="Top"/>
          

TextBox =  <TextBox x:Name="txtText1" HorizontalAlignment="Left" Height="72" Margin="10,296,-10,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="456"/>


        

4. Masuk Ke Event Klik Button dan tuliskan scrip di bawah ini

 private void Button_Click_1(object sender, RoutedEventArgs e)
        {

            if (Checkbox1.IsChecked == true)
            {
                txtText1.Text = "CheckBox1 Checked";
                if (Radio1.IsChecked == true)
                {
                    txtText1.Text = "CheckBox1 dan RadioButton Checked";
                }
                else
                {
                    txtText1.Text = "RadioButton unChecked";
                }

            }
            else
            {
                txtText1.Text = "CheckBox1 dan RadioButton unChecked";
            }

            // Sample code for building a localized ApplicationBar
            //private void BuildLocalizedApplicationBar()
            //{
            //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
            //    ApplicationBar = new ApplicationBar();

            //    // Create a new button and set the text value to the localized string from AppResources.
            //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
            //    appBarButton.Text = AppResources.AppBarButtonText;
            //    ApplicationBar.Buttons.Add(appBarButton);

            //    // Create a new menu item with the localized string from AppResources.
            //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
            //    ApplicationBar.MenuItems.Add(appBarMenuItem);
            //}
        }
    }

Run dan hasilnya seperti di bawah ini

3

Selamat Mengerjakan

Advertisements

Published by

jarcode

hello I am jarcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s