Pages

Monday, September 21, 2009

Save a datetime into SQL Server 2005 in dd/MM/yyyy format By Praveen P.R

y//C#
//Save datetime in dd/MM/yyy formate into DataBase

//While Insert statement
e.g
Insert into ....purchaseDate="'+ DateTime.ParseExact(dateTimeField.Value.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture.DateTimeFormat)+"' .....;

//While Select statement
 e.g
Select
convert(datetime,purchaseDate,103) =convert(datetime,'" + DateTime.ParseExact(dateTimeField.Value.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture.DateTimeFormat) + "',103) ,.........from tablename

http://www.prpraveen.blogspot.com

Datetime Null insertion to DataBase By Praveen P.R

//C#
//Datetime Null insertion to DB

using System.Data.SqlTypes;

//Any Datetime variable
//e.g dtToday
dtToday= SqlDateTime.Null;

http://www.prpraveen.blogspot.com

Sunday, September 20, 2009

DataGridView ComboBox Single click DropDown By Praveen P.R

// C#//It is also possible to drop down the comboboxlist using the DataGridViewComboBoxEditingControl when catching a mouse event:


 private void dgvCompanyList_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  {
  if(dgvCompanyList[e.ColumnIndex, e.RowIndex].EditType.ToString() == "System.Windows.Forms.DataGridViewComboBoxEditingControl")
  {
  DataGridViewColumn column = dgvCompanyList.Columns[e.ColumnIndex];
  if (column is DataGridViewComboBoxColumn)
  {
  DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dgvCompanyList[e.ColumnIndex, e.RowIndex];
  dgvCompanyList.CurrentCell = cell;
  dgvCompanyList.BeginEdit(true);
  DataGridViewComboBoxEditingControl editingControl = (DataGridViewComboBoxEditingControl)dgvCompanyList.EditingControl;
  editingControl.DroppedDown = true;
  }
  }
  }
http://www.prpraveen.blogspot.com

How to trigger a button click event By Praveen P.R

//C#

 button1.PerformClick();
 button1_Click(null, null);

prpraveen.blogspot.com

Monday, September 14, 2009

GlassButton / Custom button C# By Praveen P.R


http://www.prpraveen.blogspot.com
Codeproject

 * GlassButton - How to create an animating glass button using only GDI+ (and not using WPF). *
 * *
 * Original developed by Łukasz Świątkowski - lukasz.swiatkowski@gmail.com *
 * Form-/Perfomance-/Behavior-Improvements by Fink Christoph - fink.christoph@gmail.com *
 * *
 * Perfomance-Timer stoped for slow systems
 * Feel free to use this control in your application or to improve it in any way! *
 ***********************************************************************************************/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using PushButtonState = System.Windows.Forms.VisualStyles.PushButtonState;

namespace EnhancedGlassButton
{
  ///
  /// Represents a glass button control.
  ///

  [ToolboxBitmap(typeof(System.Windows.Forms.Button)), ToolboxItem(true), ToolboxItemFilter("System.Windows.Forms"), Description("Raises an event when the user clicks it.")]
  public partial class GlassButton : Button
  {
  # region " Global Vareables "

  # region " Vareables for Drawing "

Sunday, September 6, 2009

Set Focus to a control on Form Load C# by Praveen P.R

// On form Load as  required
this.ActiveControl = controlName;

Clear all controls on a Form / Panel / GroupBox etc c# by Praveen P.R

 //Clear All values in the Form / Panel / GroupBox  etc
  public static void clearControls(Control crl)
  {
  foreach (Control c in crl.Controls)
  {
  if (c.GetType().Name == "GroupBox" || c.GetType().Name == "CustomGroupBox")
  {
  clearControls(c);
  }
  else if (c.GetType().Name == "TextBox")
  {
  ((TextBox)c).Text = "";
  }
  else if (c.GetType().Name == "CustomTextBox")
  {
  ((CustomControls.CustomTextBox)c).Text = "";
  }
  else if (c.GetType().Name == "ComboBox")
  {
  if (((ComboBox)c).Items.Count > 0)
  {
  ((ComboBox)c).SelectedIndex = 0;
  }
  }
  }
  }
//To call the above funtion

clearControls(this);
or
clearControls(panel); // pass panel Object

or
clearControls(Groupbax); // pass groupbax Object