Friday, 28 June 2013

Visual Studio 2008 - Toolbar missing 'Release' / 'Debug' dropdown build configuration

It describes how to get this useful dropdown visible:
  1. In Visual Studio 2008, click “Tools” -> “Options”

  1. Under “Projects and Solutions” -> “General”, check “Show advanced build options”, and click “OK”
 
          2.Right click anywhere in the blank space of the toolbar and click “Customize…”

      
       3.In “Commands” tab, select “Build” in “Categories”.

4. Scroll the right listbox to the bottom and drag “Solution Configurations” to the toolbar

Tuesday, 4 June 2013

C# - Equivalent to the function GetSetting() in VB .NET

Getsetting DLL Download

using Microsoft.Win32;


public static string GetSetting(string applicationName, string sectionName, string key, string valeurParDéfaut)
        {
            StringBuilder path;
            RegistryKey registryKey;

            path = new StringBuilder(@"Software\VB and VBA Program Settings");

            // Generate the path of the key
            if (string.IsNullOrEmpty(applicationName) == false)
            {
                path.Append('\\');
                path.Append(applicationName);

                if (string.IsNullOrEmpty(sectionName) == false)
                {
                    path.Append('\\');
                    path.Append(sectionName);
                }
            }
            // Open key
            registryKey = Registry.CurrentUser.OpenSubKey(path.ToString());


            // If the key does not exist, return the default Open key
            if (registryKey == null)
            {
                return valeurParDéfaut;
            }
            try
            {
                //Read the value contained in the key
                return (string)registryKey.GetValue(key, valeurParDéfaut);
            }
            finally
            {
                //registryKey.Dispose();
            }
        }

public static string GetSetting(string applicationName, string sectionName, string key)
        {
            return GetSetting(applicationName, sectionName, key, null);
        }


//It is now possible to use this class like this:
string s;
            s= Getsetting.Form1.GetSetting("JRFleetini", "DatabasePathini", "dbPathini", null);
            MessageBox.Show(s);

Friday, 24 May 2013

textbox - wait for user to finish typing in a Text Box

private void txtBusinessName_TextChanged(object sender, EventArgs e)
{
            TimerKey = 3000;
            timer1.Interval = TimerKey;
            timer1.Enabled = true;
}

private void timer1_Tick(object sender, EventArgs e)
{
          SearchFirstTextbox();
            timer1.Enabled = false;
}

public void SearchFirstTextbox()
{
           string searchList = "<sreacn Key Word>";
            int col = 1;
            int colCount = col + 1;

            for (int lvelist = 0; lvelist < listview1.Items.Count; lvelist++)
            {
                if (listview1.Items[lvelist].Text.ToLower().Contains(searchList.ToLower()))
                {
                    listview1.TopItem = lvwClientInformation.Items[lvelist];
                    listview1.Items[lvelist].Selected = true;
                    listview1.Select();
                    lvelist = listview1.Items.Count;
                }
}

Thursday, 23 May 2013

Display Time with the DateTimePicker Control

Display Time with the DateTimePicker Control

datetimePicker.Format = DateTimePickerFormat.Time;
datetimePicker.ShowUpDown = true; 

Comobo Box Hide / Not Type (Key press)

Solutions :  
private void ComoboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
            e.Handled = true;
}

shortcuts in C# Windows Form

Solutions :   

private void frmPartsFormWizard_KeyDown(object sender, KeyEventArgs e)
{
            if (Control.ModifierKeys == Keys.Alt && e.KeyCode == Keys.S)
            {
                txtbox1.Focus();
            }
            else if (Control.ModifierKeys == Keys.Alt && e.KeyCode == Keys.R)
            {
                txtbox2.Focus();
            }
}

Wednesday, 22 May 2013

string[] remove null (string array remove Null)

string[] items = new string[]
{ "", "Name1", "Name2", null, "Name3", "Name4", null, "Name5" };
 
Solutions :   
items = items.Where(s => !String.IsNullOrEmpty(s)).ToArray();