Create a WPF project and add a button to the form.
Here is the XAML code.
The C# code for the button is
The user interface is something like this
Here is the XAML code.
<Window x:Class="SystemName.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Name="btnmachinename" Height="24" Width="100" Content="Display" Click="btnmachinename_Click"
/>
</Grid>
</Window>
|
The C# code for the button is
private void
btnmachinename_Click(object sender, RoutedEventArgs e)
{
string
CName=System.Environment.MachineName;
MessageBox.Show(CName);
}
|
The user interface is something like this
No comments:
Post a Comment