Saturday, 14 September 2013

Color to RGB and hex Value

HexConverter
 
DialogResult result = colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
    Color c=colorDialog1.Color;
    string HexConverter= "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
}

RGBConverter

DialogResult result = colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
    Color c=colorDialog1.Color;
    string HexConverter= "RGB(" + c.R.ToString() + "," + c.G.ToString() + "," + c.B.ToString() + ")";
}

Tuesday, 10 September 2013

C# array null/empty string values

String[] URL= {"1","2","","4","6",""};

var temp = new List<string>();
foreach (var s in URL)
{
         if (!string.IsNullOrEmpty(s))
         {
              temp.Add(s);
}
URL = temp.ToArray();

Monday, 1 July 2013

How to remove recent projects from Visual Studio Start Page

To remove the projects from the list, follow these steps:
  1. Close Visual Studio if it is running.
  2. Start the Registry Editor (run regedit).
    Registry Editor
  3. Navigate to this registry key:
    HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList
    Registry Editor 2
  4. Then delete the key that has the project you do not want to keep in the list.

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;