I found the codePlex Project Exporter.codeplex.com more useful for my application
where u can export the datatable List to Word / Excel / PDF / HTML.
where it worked for windows Application without an issue.
when i added it to the web application it failed. Here is the fix..
Exporter need to change in code for web and windows application. So its better to determine the type of application accessing it and access the template.
Add reference System.Web; to ExportDLL and declare a Property setter as follows.
public static bool IsWebApplication
{
get
{
try
{
System.Web.HttpContext Context = System.Web.HttpContext.Current;
if (Context != null)
return true;
}
catch { }
return false;
}
}
and in the StringTemplateGroup Check the application is web and set the Server.MapPath for PathFiles
private static StringTemplateGroup stgCollection
{
get
{
string where = @"templates\Collection";
if (IsWebApplication)
PathFiles = System.Web.HttpContext.Current.Server.MapPath("bin");
if (!string.IsNullOrEmpty(PathFiles))
{
where = Path.Combine(PathFiles, where);
}
StringTemplateGroup stg = new StringTemplateGroup("Collection", where);
stg.RegisterAttributeRenderer(typeof(string), new AdvancedStringRenderer());
stg.RegisterAttributeRenderer(typeof(DateTime), new AdvancedDateTimeRenderer());
return stg;
}
}
and here is the link
http://exporter.codeplex.com/Project/Download/FileDownload.aspx?DownloadId=163747
Friday, November 5, 2010
Thursday, August 27, 2009
Windows Programming - Working with MouseMove
using System;
using System.Windows.Forms;
using System.Drawing;
class myfrm : Form
{
public myfrm()
{
this.MouseMove +=new MouseEventHandler(fun);
}
void fun(object o, MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
g.DrawEllipse(Pens.Red, e.X - 50, e.Y - 50, 100, 100);
}
}
class Program
{
static void Main(string[] args)
{
myfrm f = new myfrm();
f.ShowDialog();
}
}
using System.Windows.Forms;
using System.Drawing;
class myfrm : Form
{
public myfrm()
{
this.MouseMove +=new MouseEventHandler(fun);
}
void fun(object o, MouseEventArgs e)
{
Graphics g = this.CreateGraphics();
g.DrawEllipse(Pens.Red, e.X - 50, e.Y - 50, 100, 100);
}
}
class Program
{
static void Main(string[] args)
{
myfrm f = new myfrm();
f.ShowDialog();
}
}
Windows Programming - Working with ContextMenu OR right click menu
using System;
using System.Windows.Forms;
using System.Drawing;
class myfrm : Form
{
ContextMenu cm;
MenuItem m1, m2, m3;
public myfrm()
{
cm = new ContextMenu();
m1 = new MenuItem("aaa");
m2 = new MenuItem("bbb");
m3 = new MenuItem("ccc");
cm.MenuItems.Add(m1);
cm.MenuItems.Add(m2);
cm.MenuItems.Add(m3);
this.ContextMenu = cm;
m1.Click +=new EventHandler(fun);
}
void fun(object o, EventArgs e)
{
MessageBox.Show("m1 clicked");
}
}
class Program
{
static void Main(string[] args)
{
myfrm f = new myfrm();
f.ShowDialog();
}
}
using System.Windows.Forms;
using System.Drawing;
class myfrm : Form
{
ContextMenu cm;
MenuItem m1, m2, m3;
public myfrm()
{
cm = new ContextMenu();
m1 = new MenuItem("aaa");
m2 = new MenuItem("bbb");
m3 = new MenuItem("ccc");
cm.MenuItems.Add(m1);
cm.MenuItems.Add(m2);
cm.MenuItems.Add(m3);
this.ContextMenu = cm;
m1.Click +=new EventHandler(fun);
}
void fun(object o, EventArgs e)
{
MessageBox.Show("m1 clicked");
}
}
class Program
{
static void Main(string[] args)
{
myfrm f = new myfrm();
f.ShowDialog();
}
}
Subscribe to:
Posts (Atom)