Skip to main content

Posts

Print and PrintPreview in C# Windows Application

In this article; we gonna see how to make print and preview options in C# windows application 1. Design View of the windows Form 2. Code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace PrintOptions { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //printdocument associated with richTextbox value private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawString(richTextBox1.Text, richTextBox1.Font, Brushes.Black, 100, 20); e.Graphics.PageUnit = GraphicsUnit.Inch; } // print button private void button1_Click(object sender, EventArgs e) { printDialog1.Document = printDocu...

Data Display Form Using DataGridview tool in C# Windows Application

1. Design Form  Steps: a. Choose Datagridview tool in tool kit b. Choose new datasource from datagridview c. After choosing particular database and data table the design of form will be look a like in this above acreenshot 2. Class view for data table  3. Code created automatically using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using System.Data.Sql; namespace DataDisplayForm { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'nameDBDataSet.namedata' table. You can move, or remove it, as needed. this.namedataTableAdapter.Fill(this.nameDBDataSet.name...

C# Windows Application Data Form sample Module: Save and Retrieve Data using MS SQL database

Methods Used: 1. Created a database as NameDB and Database table as namedata as follows. --table for saving retrieving datas create table namedata (  ID int identity,  Firstname nvarchar(500),  Secondname nvarchar(500),  Fullname nvarchar(500) ) --get  query result select * from namedata 2. Create a  stored procedure for saving data -- creating stored procedure for saving data create proc nameprocedure  @Firstname as nvarchar(500), @Secondname as nvarchar(500), @Fullname as nvarchar(500) as begin   SET NOCOUNT ON; Insert into  namedata(Firstname,Secondname,Fullname) values(@Firstname,@Secondname,@Fullname) end -- execute strored procedure exec nameprocedure 3. Windows Application design for save and Retrieve data form set formborderstyle as none 4. App.config settings to Connect database <?xml version="1.0"?> <configura...

Java Swing Full Screen window Application without Maximize, Minimize, Exit Buttons

Code For FullScreen Java Swing Desktop Application package fullscreen; import java.awt.Toolkit; import javax.swing.JFrame; public class FullScreen extends JFrame { /** * full screen code using Java Swing component JFrame */ static JFrame f= new FullScreen(); public FullScreen() { setUndecorated(true); //removing Max, min, Exit buttons setSize(Toolkit.getDefaultToolkit().getScreenSize()); //set window size as full screen setVisible(true); } public static void main(String[] args) { // no code here } } Output Screen 

Getting Distance and Traveling Time (Bus Mode) Details from Google Maps in ASP.NET C# using Google Maps API XML & XPath Webservice

Description: 1. In Design View Coding, add the Javascript Code in Head section to make an integration with Google Maps API Script.     <script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"         type="text/javascript"></script> 2. Add the Source and Destination functions inside script tags, which is indicating the locations function Source() {             try {                 var input = document.getElementById('TextBox1');                 var autocomplete = new google.maps.places.Autocomplete(input);                 autocomplete.setTypes('changetype-geocode');             }             catch (err) {                 //...

Show your Current Location in Google Maps using ASP.NET C# website and Google Maps API

Descriptions: Add this script tag inside <Head> section " <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyByJmQq7PkPaznZUFsH7AesFNUz82U8iOc&sensor=false"> </script> " Inside this Script add your own Key value  [ key=AIzaSyByJmQq7PkPaznZUFsH7AesFNUz82U8iOc]   from Google Code  https://code.google.com/apis/console/ 1. Getting User Location function in Javascript coding        function success(position) {         var latitude = position.coords.latitude;         var longitude = position.coords.longitude;         var city = position.coords.locality;         var myLatlng = new google.maps.LatLng(latitude, longitude);         var myOptions = {             center: myLatlng,             zoom: 12,    ...

Auto Calculation in Textbox textchanged event in ASP.NET C#

Screen Shot Coding 1. Design Coding Sample Text Change Event for Auto-Calculations Auto Calculations                                                                          Press Tab here to generate auto calculate values 2. Code Behind using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void TextBox2_TextChanged(object sender, EventArgs e) { if (TextBox1.Text == " ") { TextBox1.Text = "Enter Some values here"; } else {...