Contains classes for creating Windows-based applications using features available in the Microsoft Windows operating system.
Search This Blog
Monday, March 17, 2014
Wednesday, March 12, 2014
MessageBox C# Example
C# > Forms > MessageBox
Examples:
A. Displays a message box with specified text.
MessageBox.Show("Text message");
B. Displays a message box with specified text, caption, and buttons.
string message = "Do you want to close this windows?";
Examples:
A. Displays a message box with specified text.
B. Displays a message box with specified text, caption, and buttons.
string message = "Do you want to close this windows?";
string caption = "Question";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = MessageBox.Show(message, caption, buttons);
if (result == System.Windows.Forms.DialogResult.Yes)
{
this.Close();
}
Etichete:
c#
Monday, March 10, 2014
AppActivate Visual Basic
VB.NET > Functions > AppActivate
Activates an application that is already running.
Example:
Start and activate notepad
Activates an application that is already running.
Example:
Start and activate notepad
AppActivate(Shell("C:\Windows\System32\notepad.exe", AppWinStyle.NormalFocus))
Etichete:
VB.NET
Thursday, March 6, 2014
C# Random Color
C# > Color > Random
Random rnd = new Random();
Color randomColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));
Etichete:
c#
Change DataGridView column to Hyperlink Runtime
C# > DataGridView > DataGridViewLinkCell
Example: Change DataGridView column to Hyperlink Runtime
Example: Change DataGridView column to Hyperlink Runtime
foreach (DataGridViewRow r in dgv.Rows)
{
DataGridViewLinkCell lc = new DataGridViewLinkCell();
lc.Value = r.Cells[1].Value;
dgv[1, r.Index] = lc;
}
private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1)
return;
if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewLinkCell)
{
string link = "http://www...";
if(e.ColumnIndex == 1)
System.Diagnostics.Process.Start(link + dgv.Rows[e.RowIndex].Cells[4].Value as string);
}
}
Etichete:
c#
Read save data to Registry C# Example
C# > Win32 > RegistryKey
RegistryKey represents a key-level node in the Windows registry
Example:
Save user name to registry
RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("MyProgram");
if (regKey == null)
regKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("MyProgram");
if (regKey.GetValue("User", "") == null)
{
regKey.SetValue("User", txtUser.Text);
}
else
{
if (txtUser.Text != regKey.GetValue("User", "").ToString())
{
regKey.SetValue("User", txtUser.Text);
}
}
regKey.Close();
Etichete:
c#
Subscribe to:
Posts (Atom)