Date Format plays a major role in windows application development in c#.
Because by default, Its set to our Regional Settings's Date Format (Control Panel).If you change Regional Settings's Date Format then your windows application's Format will automatically gets changed.
If you design an application for single System means There is no problem.But If it's Multi User(LAN) & accessed from different system means problem will occur.because each system may have different date formats.
and By Default It set to US format mm/dd/yyyy.But in INDIA we need date in dd/mm/yyyy.so we have to change culture information of our application.Like Below
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");
Here,
FR refers FRANCE.
for INDIA we can set it as hi-IN(hindi),ta-IN(tamil) for each language.
Just add This Line in Main Form Loading Event.Then in entire Application All Date Conversion methods will have format as dd/mm/yyyy only.
If you want to set different culture info means you can add this line where you need to set a culture at run time.
And also if you retrieve date from a File or some where else as String then after that if you convert it into Date means,It will converted into dd/mm/yyyy format Only.
So we can set DATE FORMAT for entire windows application with the help of above culture settings.
Thank you.
It's all about my thoughts about the people, happenings, films, sports, books, problems, programmings I came across in my life.
Wednesday, May 20, 2009
Saturday, May 9, 2009
Silver Member in c# corner website
Today I become a Silver member of C#Corner.I have joined in c# corner on 7th January.I get into this position with in 4 months.
Since January, I posted 200 posts and 2 articles in c# corner.I have learnt many things from c#corner.I have good friends in c#corner.c# corner Makes differences in my programming life.my confidence level on programming was increased.
Take a look on my profile on c# corner
Vimal Kandasamy Profile
Since January, I posted 200 posts and 2 articles in c# corner.I have learnt many things from c#corner.I have good friends in c#corner.c# corner Makes differences in my programming life.my confidence level on programming was increased.
Take a look on my profile on c# corner
Vimal Kandasamy Profile
Tuesday, May 5, 2009
MVC Award in C#Corner
C#corner announces MVA & MVC For Jan,Feb,Mar months.I got MVC-Most Valuable Contributor award.MVC award is given to people who contributed in c#corner Forum.
This is my First award through Internet.I have learnt a lot through c#corner.and i just give something back to them and now i got this prestigious award.
Thanks to c#corner team.
To know more, read this news
MVA and MVC for Jan - March 2009 Announced
This is my First award through Internet.I have learnt a lot through c#corner.and i just give something back to them and now i got this prestigious award.
Thanks to c#corner team.
To know more, read this news
MVA and MVC for Jan - March 2009 Announced
Monday, May 4, 2009
Execute Another Process or File using c#
Execute another Process or Open a File using its Application is very simple in C#.
There is Separate Name space "System.Diagnostics" is available
There is class named as Process will execute all kind process.
If you want to execute a Exe or open File then a single line can do this
i.e
Process.Start(filepath);
Ex1:
Process.Start("c:\\windows\\notepad.exe");
This statement will open a NotePad Application
Ex2:
Process.Start("c:\\a.doc");
It will Open a.doc File in Word Application.This is applicable to All kind Executable Files.
If you want to give some command line Arguments means use
Process p = new Process();
p.StartInfo.FileName = "c:\\windows\\notepad.exe"; //exe path
p.StartInfo.Arguments = "c:\\a.txt"; //filepath
p.Start();
And also we have more No of options in Process class.
Start Time,End Time,Priority,Memory size,Availability etc.you can start,stop a Process.
If you want to run a process in background
then use following statement.
p.StartInfo.CreateNoWindow = true;
Thank you.
There is Separate Name space "System.Diagnostics" is available
There is class named as Process will execute all kind process.
If you want to execute a Exe or open File then a single line can do this
i.e
Process.Start(filepath);
Ex1:
Process.Start("c:\\windows\\notepad.exe");
This statement will open a NotePad Application
Ex2:
Process.Start("c:\\a.doc");
It will Open a.doc File in Word Application.This is applicable to All kind Executable Files.
If you want to give some command line Arguments means use
Process p = new Process();
p.StartInfo.FileName = "c:\\windows\\notepad.exe"; //exe path
p.StartInfo.Arguments = "c:\\a.txt"; //filepath
p.Start();
And also we have more No of options in Process class.
Start Time,End Time,Priority,Memory size,Availability etc.you can start,stop a Process.
If you want to run a process in background
then use following statement.
p.StartInfo.CreateNoWindow = true;
Thank you.
Thursday, April 30, 2009
Access a Form's Control from another Form
We Can access a Form's Control such as TextBox,ComboBox,datagridview etc. From another Form by passing current Form Object into another Form via an Overloaded constructor.
Ex:
In form 1
Form2 f1 = new Form2(this);
f1.ShowDialog();
then In Form2
Form1 form1;
public Form2(Form1 f)
{
InitializeComponent();
this.form1 = f;
}
we can easily access form1's TextBox like
form1.textBox1.Text="Hi,This is Form2";
Note : Modifiers property of Form1's TextBox1 should be declared as Public.
Thank you
Ex:
In form 1
Form2 f1 = new Form2(this);
f1.ShowDialog();
then In Form2
Form1 form1;
public Form2(Form1 f)
{
InitializeComponent();
this.form1 = f;
}
we can easily access form1's TextBox like
form1.textBox1.Text="Hi,This is Form2";
Note : Modifiers property of Form1's TextBox1 should be declared as Public.
Thank you
Passing Information between Windows Forms
We can Pass Information from One Form to another Form
via an Overloaded Constructor.
In form1,we have to pass value in constructor on Object Creation.
Ex:
Form2 f2 = new Form2(UserName);
f2.ShowDialog();
Then in Form2,we have to assign Passed value in a Local variable or control.
Here UserName refers a String Variable which contains User Name entered in form1.
Ex:
String uname;
public Form2(String username)
{
InitializeComponent();
textBox1.Text =username ;
uname=username;
}
Now textBox1 & variable uname contains value Entered in Form1
Thank you.
via an Overloaded Constructor.
In form1,we have to pass value in constructor on Object Creation.
Ex:
Form2 f2 = new Form2(UserName);
f2.ShowDialog();
Then in Form2,we have to assign Passed value in a Local variable or control.
Here UserName refers a String Variable which contains User Name entered in form1.
Ex:
String uname;
public Form2(String username)
{
InitializeComponent();
textBox1.Text =username ;
uname=username;
}
Now textBox1 & variable uname contains value Entered in Form1
Thank you.
Monday, April 20, 2009
My First Website
I just built a website for JK Constructions which is the first website developed by me ever.In College Days, I have created some website templates for a German company through my brother. On those days, I just copied some samples from websites and try to build templates using HTML.
But Now i built a website using ASP.NET,C#.NET & XML.In My UG project, i have used XML for storing data.In the beginning, i have some doubts on XML ability to use it as database.But at the end, I m very much satisfied with XML.
All works such as designing,coding,Registering domain,hosting website are done by me without any help.
It is a very good experience for me.I m the only and only person from computer filed in that company.All are from construction field.Its very tough to understand their requirements.and the thing which is too tough is to explain the limitations of a website.I have learnt a lot of good lessons on those days.
take a look on my fist website
JK constructions
But Now i built a website using ASP.NET,C#.NET & XML.In My UG project, i have used XML for storing data.In the beginning, i have some doubts on XML ability to use it as database.But at the end, I m very much satisfied with XML.
All works such as designing,coding,Registering domain,hosting website are done by me without any help.
It is a very good experience for me.I m the only and only person from computer filed in that company.All are from construction field.Its very tough to understand their requirements.and the thing which is too tough is to explain the limitations of a website.I have learnt a lot of good lessons on those days.
take a look on my fist website
JK constructions
Wednesday, April 15, 2009
JAVA Simple Printing
PrintJob class is used for printing in JAVA.
you have to format the things which you need to take printout.
you can draw rectangle,line any graphics object and also string.
you can set Font & Color for that
EX:
PrintJob job = getToolkit().getPrintJob(fr,"PRINT",null);
Graphics g=job.getGraphics();
g.drawRect(50,30,525,775);
g.setFont(new Font("TimesRoman",Font.BOLD,16));
g.drawString("Welcome to JAVA",220,50);
g.drawLine(50,80,50,500);
g.dispose();
job.end();
Here
fr refers frame object.
g.drawRect(xposition,yposition,width,height);
g.drawString("String to print",Xposition,yposition);
g.drawLine(StartX,StartY,EndX,Endy);
output:
This will draw a rectangle... It will be the complete border for A4 sheet.
after that draw "Welcome to JAVA in TimesRoman font with bold.
And draw Line
then it End the print job
Thank you
you have to format the things which you need to take printout.
you can draw rectangle,line any graphics object and also string.
you can set Font & Color for that
EX:
PrintJob job = getToolkit().getPrintJob(fr,"PRINT",null);
Graphics g=job.getGraphics();
g.drawRect(50,30,525,775);
g.setFont(new Font("TimesRoman",Font.BOLD,16));
g.drawString("Welcome to JAVA",220,50);
g.drawLine(50,80,50,500);
g.dispose();
job.end();
Here
fr refers frame object.
g.drawRect(xposition,yposition,width,height);
g.drawString("String to print",Xposition,yposition);
g.drawLine(StartX,StartY,EndX,Endy);
output:
This will draw a rectangle... It will be the complete border for A4 sheet.
after that draw "Welcome to JAVA in TimesRoman font with bold.
And draw Line
then it End the print job
Thank you
Tuesday, April 14, 2009
JAVA Message,Input and Confirm Dialog Box
In java JOptionPane class is used to show Message and also used to get Input from user
Message Box
There are different type of Message Box are available Normal,Error and Warning message box
JOptionPane.showMessageDialog("your Message","Title");
Error Message
JOptionPane.showMessageDialog("your Message","Title",JOptionPane.ERROR_MESSAGE);
Warning Message
JOptionPane.showMessageDialog("your Message","Title",JOptionPane.WARNING_MESSAGE);
Input Box
In order to get a value from user. we can use showInputDialog() Method.
we have to Pass current frame object to that msg
String value=JOptionPane.showInputDialog(fr,"Plz enter Value ");
Input Box with Default value
String value=JOptionPane.showInputDialog(fr,"Plz enter Value ","Default value");
Confirm Dialog
This can be used with following options
Yes No
Retry Ignore Cancel
OK Cancel
Ex for YES NO confirm Dialog
int result=JOptionPane.showConfirmDialog(fr,"Do you Want to Save it","Save",JOptionPane.YES_NO_OPTION);
Note :
here,
result contains 0 or 1..
o refers YES and 1 refers NO
fr -> frame object
"Do you Want to Save it", -> Question
"Save", ->Header
JOptionPane.YES_NO_OPTION -> Option
Thank you
Message Box
There are different type of Message Box are available Normal,Error and Warning message box
JOptionPane.showMessageDialog("your Message","Title");
Error Message
JOptionPane.showMessageDialog("your Message","Title",JOptionPane.ERROR_MESSAGE);
Warning Message
JOptionPane.showMessageDialog("your Message","Title",JOptionPane.WARNING_MESSAGE);
Input Box
In order to get a value from user. we can use showInputDialog() Method.
we have to Pass current frame object to that msg
String value=JOptionPane.showInputDialog(fr,"Plz enter Value ");
Input Box with Default value
String value=JOptionPane.showInputDialog(fr,"Plz enter Value ","Default value");
Confirm Dialog
This can be used with following options
Yes No
Retry Ignore Cancel
OK Cancel
Ex for YES NO confirm Dialog
int result=JOptionPane.showConfirmDialog(fr,"Do you Want to Save it","Save",JOptionPane.YES_NO_OPTION);
Note :
here,
result contains 0 or 1..
o refers YES and 1 refers NO
fr -> frame object
"Do you Want to Save it", -> Question
"Save", ->Header
JOptionPane.YES_NO_OPTION -> Option
Thank you
JAVA Table with Combobox control
In java swing we can add Controls in table.
Here we are going to add Combobox in a table control.
Before going to create a table instance, we have to create table headers and data with empty strings like below
final String[] colheads={"S.No","Item ID","Qty",Rate","Amount" };
final Object[][] data={
{1,"","","",""},
{2,"","","",""},
{3,"","","",""},
{4,"","","",""},
{5,"","","",""},
};
Now we create a table and add scroll panes to it...
JTable table=new JTable(data,colheads);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(table,v,h);
Note: add this table into panel to show...
Then to add combo box in the run time, we add code in focus gained event of table like below..
public void focusGained(FocusEvent e)
{
TableColumn tc=table.getColumnModel().getColumn(1);
JComboBox dw=new JComboBox();
dw.addItem("Select");
dw.addItem("IN1");
dw.addItem("IN2");
dw.addItem("IN3");
dw.addItem("IN4");
tc.setCellEditor(new DefaultCellEditor(dw));
}
Note: we have to add focus listener to table and after that add code for it..in the focus gained method we have to add above code..
In the output,It will show a table.. when you access table you can able select item values at column 2...
Thank you
Here we are going to add Combobox in a table control.
Before going to create a table instance, we have to create table headers and data with empty strings like below
final String[] colheads={"S.No","Item ID","Qty",Rate","Amount" };
final Object[][] data={
{1,"","","",""},
{2,"","","",""},
{3,"","","",""},
{4,"","","",""},
{5,"","","",""},
};
Now we create a table and add scroll panes to it...
JTable table=new JTable(data,colheads);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(table,v,h);
Note: add this table into panel to show...
Then to add combo box in the run time, we add code in focus gained event of table like below..
public void focusGained(FocusEvent e)
{
TableColumn tc=table.getColumnModel().getColumn(1);
JComboBox dw=new JComboBox();
dw.addItem("Select");
dw.addItem("IN1");
dw.addItem("IN2");
dw.addItem("IN3");
dw.addItem("IN4");
tc.setCellEditor(new DefaultCellEditor(dw));
}
Note: we have to add focus listener to table and after that add code for it..in the focus gained method we have to add above code..
In the output,It will show a table.. when you access table you can able select item values at column 2...
Thank you
Sunday, March 15, 2009
View Reports through Excel
Again I wrote an article in C#corner. This time, it's about viewing reports.
We are in the need to generate Reports for Financial Statistics.and we need a format to view it Perfectly.Here i choose Character value separator as Format and Excel for Viewing it.
Please check out My article
An easy way to view reports through Excel
We are in the need to generate Reports for Financial Statistics.and we need a format to view it Perfectly.Here i choose Character value separator as Format and Excel for Viewing it.
Please check out My article
An easy way to view reports through Excel
Tuesday, March 10, 2009
My First Article - "Xml - A Simple Database"
I wrote one article about XML.This is first time on Internet. Its Titled as
In this article, I discussed about How to use XML as a database for your Application.
Here I mentioned the techniques used to create and Maintain a database such as read,Write,Update &Remove an XML data.
please take a look on my article
Xml - A Simple Database
Thank you
Xml - A Simple Databaseand published on C#corner website.
In this article, I discussed about How to use XML as a database for your Application.
Here I mentioned the techniques used to create and Maintain a database such as read,Write,Update &Remove an XML data.
please take a look on my article
Xml - A Simple Database
Thank you
Subscribe to:
Posts (Atom)