Hi,
If you are using div. Sometimes the div may overflow in IE6 browser.This is due to nesting of various div.So check the div top position.If u find placing of any div, overflows the existing div. Plz change the top to margin-top property to avoid overflow of particular div.
Friday, December 26, 2008
Friday, December 19, 2008
Refresh() method in Windows Application
Hi,
Refresh() -Forces the control to Invalidate its client area and Immediately redraw itself and its child control.
we can use either Refresh() or invalidate() methods to redraw the client area with the updated position. If you want to drag an image inside the picturebox,you must use any one of these methods.
Refresh() -Forces the control to Invalidate its client area and Immediately redraw itself and its child control.
we can use either Refresh() or invalidate() methods to redraw the client area with the updated position. If you want to drag an image inside the picturebox,you must use any one of these methods.
Wednesday, December 17, 2008
To get ShortMonth in C#.net
Hi,
Use the below coding to get the short month,
public static string GetShortMonth(object aDate)
{
DateTime actualDate = (DateTime)aDate;
int day = actualDate.Day;
int monthNumber = actualDate.Month;
string month = "";
if (monthNumber == 1)
{
month = "Jan,";
}
else if (monthNumber == 2)
{
month = "Feb,";
}
else if (monthNumber == 3)
{
month = "Mar,";
}
else if (monthNumber == 4)
{
month = "Apr,";
}
else if (monthNumber == 5)
{
month = "May,";
}
else if (monthNumber == 6)
{
month = "Jun,";
}
else if (monthNumber == 7)
{
month = "Jul,";
}
else if (monthNumber == 8)
{
month = "Aug,";
}
else if (monthNumber == 9)
{
month = "Sep,";
}
else if (monthNumber == 10)
{
month = "Oct,";
}
else if (monthNumber == 11)
{
month = "Nov,";
}
else if (monthNumber == 12)
{
month = "Dec,";
}
int year = actualDate.Year;
return month + " " + day.ToString() + " " + year.ToString();
}
Use the below coding to get the short month,
public static string GetShortMonth(object aDate)
{
DateTime actualDate = (DateTime)aDate;
int day = actualDate.Day;
int monthNumber = actualDate.Month;
string month = "";
if (monthNumber == 1)
{
month = "Jan,";
}
else if (monthNumber == 2)
{
month = "Feb,";
}
else if (monthNumber == 3)
{
month = "Mar,";
}
else if (monthNumber == 4)
{
month = "Apr,";
}
else if (monthNumber == 5)
{
month = "May,";
}
else if (monthNumber == 6)
{
month = "Jun,";
}
else if (monthNumber == 7)
{
month = "Jul,";
}
else if (monthNumber == 8)
{
month = "Aug,";
}
else if (monthNumber == 9)
{
month = "Sep,";
}
else if (monthNumber == 10)
{
month = "Oct,";
}
else if (monthNumber == 11)
{
month = "Nov,";
}
else if (monthNumber == 12)
{
month = "Dec,";
}
int year = actualDate.Year;
return month + " " + day.ToString() + " " + year.ToString();
}
To Get ShortDate in C#.net
Hi,
we can get the ShortDate using the following function,
public string GetShortDate(object aDate)
{
DateTime actualDate = (DateTime)aDate;
string shortDate = "";
string month = actualDate.ToLongDateString();
string[] mon = month.Split(',');
string date = mon[1];
string year = mon[2];
shortDate = date + year;
return shortDate;
}
we can get the ShortDate using the following function,
public string GetShortDate(object aDate)
{
DateTime actualDate = (DateTime)aDate;
string shortDate = "";
string month = actualDate.ToLongDateString();
string[] mon = month.Split(',');
string date = mon[1];
string year = mon[2];
shortDate = date + year;
return shortDate;
}
To GetSubString in C#.net
Hi,
We can reduce the length of the string using getSubString function, so that the length of the string is reduced to our required length.
public string GetSubString(Object str,int len)
{
string name="";
name=str+"";
if(name.Length>len)
{
name=name.Substring(0,len);
}
return name;
}
We can reduce the length of the string using getSubString function, so that the length of the string is reduced to our required length.
public string GetSubString(Object str,int len)
{
string name="";
name=str+"";
if(name.Length>len)
{
name=name.Substring(0,len);
}
return name;
}
Implementing Paging in Datalist
Hi,
To implement paging concept in DataList use the following coding.
Here PagedDataSource is used to do paging in DataList.
Consider u r having one label named lblPagingTop to list no.of.records per page(eg. 2/6),
two hyperlinks topNextHyperLink,topPrevHyperLink for Paging.
In Code-behind have the following,
public void sampleStudPaging()
{
PagedDataSource sampleStudPagedDataSource = new PagedDataSource();
int currentPage;
try
{
if (sampleStuds.Length == 0)
{
topPrevHyperLink.Visible = false;
topNextHyperLink.Visible = false;
topLinkLabel.Visible = false;
}
if (sampleStuds.Length > 0)
{
sampleStudPagedDataSource.DataSource = sampleStuds;
sampleStudPagedDataSource.PageSize = 2;
sampleStudPagedDataSource.AllowPaging = true;
if (Request.QueryString["p"] != null)
{
currentPage = int.Parse(Request.QueryString["p"].ToString());
}
else
{
currentPage = 1;
}
sampleStudPagedDataSource.CurrentPageIndex = currentPage - 1;
if (!sampleStudPagedDataSource.IsFirstPage)
{
topPrevHyperLink.NavigateUrl = Request.CurrentExecutionFilePath + "?p=" + Convert.ToInt32(currentPage - 1);
}
else
{
topPrevHyperLink.NavigateUrl = "#";
}
if (!sampleStudPagedDataSource.IsLastPage)
{
topNextHyperLink.NavigateUrl = Request.CurrentExecutionFilePath + "?p=" + Convert.ToInt32(currentPage + 1);
}
else
{
topNextHyperLink.NavigateUrl = "#";
}
lblTopPaging.Text = "Page: " + (currentPage).ToString() + " of " + sampleStudPagedDataSource.PageCount.ToString();
SampleStudDataList.DataSource = sampleStudPagedDataSource;
SampleStudDataList.DataBind();
if (currentPage == 1)
{
topPrevHyperLink.Visible = false;
topLinkLabel.Visible = false;
}
if (currentPage == sampleStudPagedDataSource.PageCount)
{
topNextHyperLink.Visible = false;
topLinkLabel.Visible = false;
}
if (sampleStudPagedDataSource.PageCount == 1)
{
topPrevHyperLink.Visible = false;
topLinkLabel.Visible = false;
}
}
}
catch (Exception ex)
{
}
}
To implement paging concept in DataList use the following coding.
Here PagedDataSource is used to do paging in DataList.
Consider u r having one label named lblPagingTop to list no.of.records per page(eg. 2/6),
two hyperlinks topNextHyperLink,topPrevHyperLink for Paging.
In Code-behind have the following,
public void sampleStudPaging()
{
PagedDataSource sampleStudPagedDataSource = new PagedDataSource();
int currentPage;
try
{
if (sampleStuds.Length == 0)
{
topPrevHyperLink.Visible = false;
topNextHyperLink.Visible = false;
topLinkLabel.Visible = false;
}
if (sampleStuds.Length > 0)
{
sampleStudPagedDataSource.DataSource = sampleStuds;
sampleStudPagedDataSource.PageSize = 2;
sampleStudPagedDataSource.AllowPaging = true;
if (Request.QueryString["p"] != null)
{
currentPage = int.Parse(Request.QueryString["p"].ToString());
}
else
{
currentPage = 1;
}
sampleStudPagedDataSource.CurrentPageIndex = currentPage - 1;
if (!sampleStudPagedDataSource.IsFirstPage)
{
topPrevHyperLink.NavigateUrl = Request.CurrentExecutionFilePath + "?p=" + Convert.ToInt32(currentPage - 1);
}
else
{
topPrevHyperLink.NavigateUrl = "#";
}
if (!sampleStudPagedDataSource.IsLastPage)
{
topNextHyperLink.NavigateUrl = Request.CurrentExecutionFilePath + "?p=" + Convert.ToInt32(currentPage + 1);
}
else
{
topNextHyperLink.NavigateUrl = "#";
}
lblTopPaging.Text = "Page: " + (currentPage).ToString() + " of " + sampleStudPagedDataSource.PageCount.ToString();
SampleStudDataList.DataSource = sampleStudPagedDataSource;
SampleStudDataList.DataBind();
if (currentPage == 1)
{
topPrevHyperLink.Visible = false;
topLinkLabel.Visible = false;
}
if (currentPage == sampleStudPagedDataSource.PageCount)
{
topNextHyperLink.Visible = false;
topLinkLabel.Visible = false;
}
if (sampleStudPagedDataSource.PageCount == 1)
{
topPrevHyperLink.Visible = false;
topLinkLabel.Visible = false;
}
}
}
catch (Exception ex)
{
}
}
Monday, December 15, 2008
To drag image inside PictureBox
Hi,
we can drag image inside the pictureBox.
Please follow the steps one by one.
contains details about Image,Width,Height and Location.
class DraggableImage
{
public Bitmap img;
public Point Loc;
public int Width;
public int Height;
public DraggableImage(Bitmap bmpImg,Point loc)
{
this.img = bmpImg;
this.Loc = loc;
this.Width = bmpImg.Width;
this.Height = bmpImg.Height;
}
}
4. In the Form use the following coding,
public partial class Form1 : Form
{
DraggableImage di = new DraggableImage(Properties.Resources._1, new Point(0, 0));
int mx, my;
[Category("Property")]
[Description("Get and Set the draggable Image")]
public Bitmap DragImage
{
get { return di.img; }
set { di.img = value; Refresh(); }
}
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
}
private void Form1_Load(object sender, EventArgs e)
{
this.DragImage =(Bitmap)QDOES.ImageOptimizer.ResizeToMaxSize(di.img,
pictureBox1.Width, pictureBox1.Height, 96, 96);
di.Loc = new Point(pictureBox1.Left,pictureBox1.Top);
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
this.MouseDown += new MouseEventHandler(Form1_MouseDown);
this.pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown);
this.pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
di.Loc.X = e.X - mx + di.Loc.X;
di.Loc.Y = e.Y - my + di.Loc.Y;
mx = e.X;
my = e.Y;
Refresh();
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
mx = e.X;
my = e.Y;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (di != null)
{
e.Graphics.DrawImage(di.img, di.Loc);
}
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
di.Loc.X = e.X - mx + di.Loc.X;
di.Loc.Y = e.Y - my + di.Loc.Y;
mx = e.X;
my = e.Y;
Refresh();
}
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
mx = e.X;
my = e.Y;
}
}
we can drag image inside the pictureBox.
Please follow the steps one by one.
- Place PictureBox in the form.
- Set the following Properties for the PictureBox
- BackColor -> Transparent
- BackgroundImage->Give the image path of PNG file from your system.
- BackgroundImageLayout ->Stretch
- SizeMode -> Autosize
contains details about Image,Width,Height and Location.
class DraggableImage
{
public Bitmap img;
public Point Loc;
public int Width;
public int Height;
public DraggableImage(Bitmap bmpImg,Point loc)
{
this.img = bmpImg;
this.Loc = loc;
this.Width = bmpImg.Width;
this.Height = bmpImg.Height;
}
}
4. In the Form use the following coding,
public partial class Form1 : Form
{
DraggableImage di = new DraggableImage(Properties.Resources._1, new Point(0, 0));
int mx, my;
[Category("Property")]
[Description("Get and Set the draggable Image")]
public Bitmap DragImage
{
get { return di.img; }
set { di.img = value; Refresh(); }
}
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
}
private void Form1_Load(object sender, EventArgs e)
{
this.DragImage =(Bitmap)QDOES.ImageOptimizer.ResizeToMaxSize(di.img,
pictureBox1.Width, pictureBox1.Height, 96, 96);
di.Loc = new Point(pictureBox1.Left,pictureBox1.Top);
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
this.MouseDown += new MouseEventHandler(Form1_MouseDown);
this.pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown);
this.pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
di.Loc.X = e.X - mx + di.Loc.X;
di.Loc.Y = e.Y - my + di.Loc.Y;
mx = e.X;
my = e.Y;
Refresh();
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
mx = e.X;
my = e.Y;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (di != null)
{
e.Graphics.DrawImage(di.img, di.Loc);
}
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
di.Loc.X = e.X - mx + di.Loc.X;
di.Loc.Y = e.Y - my + di.Loc.Y;
mx = e.X;
my = e.Y;
Refresh();
}
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
mx = e.X;
my = e.Y;
}
}
Subscribe to:
Posts (Atom)