Skip to main content

Posts

Showing posts from June, 2013

How to show icon and text in the same cell?

  The DataGridView control does not have any built-in support for showing an icon and text in the same cell. Through the different painting customization events, such as the CellPainting event, you can easily display an icon next to the text in the cell.       The following example extends the DataGridViewTextColumn and cell to paint an image next to the text. The sample uses the DataGridViewCellStyle.Padding property to adjust the text location and overrides the Paint method to paint an icon. This sample can be simplified by handling the CellPainting event and performing similar code.      public   class   TextAndImageColumn  :  DataGridViewTextBoxColumn          {              private   Image  imageValue;              private   Size  imageSize;              public  TextAndImageColumn()              {                  this .CellTemplate =  new   TextAndImageCell ();              }              public   override   object  Clone()              {              

Connect to Oracle : A java servlet program

import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class connToHr extends HttpServlet {     public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException     {                         PrintWriter out=res.getWriter();         try         {             String conURL="jdbc:oracle:thin:@localhost:1521:orcl";             String conUSER="HR";             String conPASSWORD="HR";                String uniDriver="sun.jdbc.odbc.JdbcOdbcDriver";             Driver d=(Driver)Class.forName(uniDriver).newInstance();                Connection con=DriverManager.getConnection(conURL,conUSER,conPASSWORD);             Statement stmt=con.createStatement();             ResultSet rs;                  rs= stmt.executeQuery("SELECT * FROM EMPLOYEES");                 while(rs.next())             {                 out.println("<HTML><BODY><H1>THE EMPLOY

A Hit Count Using Java Servlet's Session Tracking

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class SessionTracker extends HttpServlet {         public void doGet(HttpServletRequest req,HttpServletResponse res)         throws ServletException,IOException         {                res.setContentType("text/html");                PrintWriter out=res.getWriter();                HttpSession session=req.getSession(true);                Integer count=(Integer)session.getValue("tracker.count");                if(count==null)                {                         count=new Integer(1);                }else{                         count=new Integer(count.intValue()+1);                }                session.putValue("tracker.count",count);                out.println("<HTML><BODY><H1>SESSION TRACKING DEMO</H1>");                out.println("You've visited this page "+count+((count.intValue()==1)?" time.":"times."