Skip to main content

Posts

Showing posts from July, 2015

How to bind a TextBox to an instance of a custom class object in WPF

If you want to bind the text box with the instance of customer class object also call one way binding in wpf. first to add a cs class in the project. In which you should take one or more public properties , i will take two public properties and one static method. That static method will return class object.  Now, your code look like:


1. Add a Class in the project also paste the below mentioned code. But remember that your class name is match with csharp file name; namespace name match with code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SplashSCreen
{
   public class Student
    {
        public string Name { get; set; }
        public string Email { get; set; }
        public static Student GetRecord()
        {
            var student = new Student();
            {
                student.Name = "Jacob";
                student.Email = "narenkumar851@gmail.com";
            };
   …

Splash Screen in WPF example

The means of splash screen is a screen through which we can show the booting process of a thread. When you start your computer then first to load booting process after then load operating system. I will do the same thing in wpf. This screen appear before loading the start page. So lets to start it:


1. First to add a new window in the project.
2. Add these properties inside window tag.

 Title="SplashScreen"
 Height="300"
Width="300"
ResizeMode="NoResize"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
Background="Green"
BorderThickness="8"
BorderBrush="Black"

3. Now, you complete code is:

<Window x:Class="SplashSCreen.SplashScreen"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:m…

Delete DataGrid row from DataGrid using entity framework(EDMX file) in WPF

Before deleting the data from the dataGrid, first to load the DataGrid using Edmx file. This is done in previous article. In this article we have new column that is DataGridTemplateColumn , in which we have cell template. When we click on button then row is deleted from DataGrid. Before deleting data from DataGrid , access emp_id from selected row .


<Window x:Class="SplashSCreen.bindgridpanel"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SplashSCreen"
        mc:Ignorable="d"
        Title="bindgridpanel" Height="300" Width="300">
    <Grid>
        <DataGrid CanUserDeleteRows="True" AutoGen…

Bind DataGrid using Entity framework (EDMX model) in wpf

In this article we will learn how to bind DataGrid using EDMX file in wpf. I already bind dataGrid in window form using EDMX. In both article, i notice that only one difference between both that is xaml file. Lets to start to design this in wpf:


<Window x:Class="SplashSCreen.bindgridpanel"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SplashSCreen"
        mc:Ignorable="d"
        Title="bindgridpanel" Height="300" Width="300">
    <Grid>
        <DataGrid AutoGenerateColumns="False" ColumnWidth="*" x:Name="dataGrid" HorizontalAlignment="Left" Margin="54,56,…

Add image in wpf window background

If you want to add image in window background of WPF application then you should use Window.Background tag in xaml. Before set the image in background you must to add the image in the solution explorer. If you add image in the subfolder then specified the path of the folder like below example.
<Window x:Class="SplashSCreen.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SplashSCreen"
        mc:Ignorable="d"
        Title="MainWindow" Height="500" Width="525">



    <Window.Background>
        <ImageBrush ImageSource="image/nokia.jpg" />
    </Window.Background>




    <Grid>

How to bind ListBox in wpf

Today i am taking about listBox in WPF. In previous articles of windows form and web form i already discussed about  ListBox. In this article i will use same control in different technology(WPF). We know that ListBox is a container of Objects. Listbox contain ItemsSource property of it which is used to bind it with the database table. You can manually define the listbox items using ListBox itemTemplate. Look at this example :


<Grid>
        <ListBox ItemsSource="{Binding Path=emp}" x:Name="listBox" HorizontalAlignment="Left" Height="225" Margin="58,48,0,0" VerticalAlignment="Top" Width="218">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding Path=Emp_Id}"/>
                        <TextBlock Text="{Binding Path=Emp_Name}" />
                    </StackPa…

Internet explorer input box show password eye button

Internet explorer's input box show the password when we click on eye button. When we press the button then show the password but when we release it then input character automatically convert into password format. Today, in this article we will design the input box whose will show the password just like eye button. This article designed in html and functionality of the article will handle by JQuery.
The complete code available in the video, so see this and learn more things about JQuery:


In this video, i have two text box, first is used for hide the password and second is used for show the password. When first time load the browser then hide second text box. When user click on show password  button then second textbox take the value of first text box also hide first text box and show second.

How to Bind Adrotator control in asp.net

Introduction
The Adrotator control displays a sequence of images, known as advertisements, on a Web page. The sequence in which the images appear can be predefined or random in nature. These advertisements, which all Internet users are familiar with, are image files in GIF, JPEG, or other format that the user can click to navigate to the advertiser's website.

Public Properties of the Adrotator Class
AdvertisementFile : Obtains or sets the path to an XML document that contain advertisement information.



Design a xml file for advertisements name as "advertisements.xml" 
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <ImageUrl>security.JPG</ImageUrl>

    <Width>
    200px
  </Width>
    <Height>
      200px
    </Height>
  </Ad>
<Ad>
    <ImageUrl>images.JPG</ImageUrl>
<Width>
    100px
  </Width>
<Height>
      200px
    </Height>
  </Ad>
</Adverti…

How to bind label control in asp.net

Step-1: Open Visual Studio IDE
Step-2 : Create New Web Project



Step-3: In Solution Explorer Add new item 

Step-4: Select web form in middle pane also select c# in left pane
Step-5: Change name of the webform as "labelbind.aspx" also select place code in separate file check box Step-6:   Right click on  Project name and add new item  again. Step-7: Open a new dialog window Select SQL SERVER database  name as a "database.mdf" Step-8: After click ok Button . a new dialog appear on the screen  Do you want to place the file in App_data folder Step-9: Click Ok Button in dialog window
Step-10: Open Server Explorer
Step-11 Make a new table inside Database

Step-12:


Step-13: fill This Table with Some value
Step-14: Open  " labelbind.aspx " page
Step-15: Drag and Drop label control onto the labelbind.aspx page from toolbox

Step-16: Add this code in Design page


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="labelbind.aspx.cs" Inh…

Student and fees management project in c#

Introduction 
This project is related to school management system. In this project we have a Sql Database to store student information also store their fees details. The main motive behind the project is to persist the student information in single place. So,we can retrieve that information easily and quickly.

Front-end and Back-end:
Front-end : Windows form with c# as business logic
Back-end :  SQL Server 2014

How to run this:


How to design the system

First to add new windows form in the solution.Add some control in the form.Now, add business logic in the code file.Module in the project Add new Student: Through this module we can add student details like : Student name, Student father name , Student mother name, Student address etc.Edit Details :  You can edit details of student by their enrollment id.Search Student details : You can search stored student details by student name. In this project we can add auto complete type functionality.Delete Student DetailsHow to Download :  Mail me :…

Use of ProgressBar in WPF also add it in Status bar with animation effect

In this article i will show you, how to use progress bar in wpf (Window Presentation Foundation) and how to add it in status bar dynamically. Actually i explained it with basic information, today i will explain more about it. In this article, first to add a status bar in the page after that add a TextBlock control in it. Now the code look like :

<Grid>
        <StatusBar Name="sbar1" Background="BlueViolet" VerticalAlignment="Bottom">             <StatusBarItem>                 <TextBlock>Status:</TextBlock>             </StatusBarItem>         </StatusBar>     </Grid>
Now, create a new function just after the InitializeComponent() method, it means you can view your progress bar on window load.  
Code behind code
using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media.Animation;
namespace WpfApplication2 {     /// <summary>     /// Interaction logic for progressba…

Accept only number by TextBox using Jquery

You can say, how to apply restriction on input using Jquery. Here, meaning of restriction is, TextBox accept only numbers. Everyone know that TextBox control take character,string, numeric and special character as a input. But in some application we need only single feature like, it accept only number. So, the first question raise in my mind, how to do this, what is the logic behind this.
Logic behind this:
First to get the key code like number 8 == backspace, some following keycode available here  Now, match the keycode with the input character, if match then input character are not allowed.Here are simple example of it: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>Accept only numbers</title> <script src="scripts/jquery-1.10.2.js"><…

Online mobile shopping project in ASP.NET

INTRODUCTION
This project is aimed at developing a Web application that depicts online Shopping of mobiles and purchasing using Payment Gateway. Using this software, companies can improve the efficiency of their services. Online Shopping is one of the applications to improve the marketing of the company’s products. This web application involves all the features of the online shopping.


The project entitled Online Mobile Shopping enables customer to buy mobiles or accessories from anywhere through online. This application advertises some of the products for shopping. To buy products, customer has to create an account. Those who does not have an account, they can only view the available product. They can’t buy it. Once the customer has created account, not only he can view the products, he can also add the product to the cart and also he can place an order to buy those products. This application then generates bill for that particular customer. After the confirmation, the customer has to…

Difference between MYSQL and MSACCESS

MYSQL is used to store data permanently also MSACCESS is used. But both are different technology so today i will discuss about difference between both.

MYSQL MSACCESS Fully RDBMS RDBMS Large application Small application Multiple DB Engine Single DB Engine More ACID(Atomicity Consistency Integrity Durability) of transaction Less ACID property of transaction Easy referential Integrity Hard Referential integrity Open source Product of Microsoft License Free License paid Good Execution Speed Poor Execution Speed Good Performance Poor performance Platform Independent Platform dependent Hard Maintenance Easy Maintenance

How to use OpenFileDialog control in wpf to read txt file

Today i am talking about OpenFileDialog control. This control is used for picking some files from computer drive or location. I have already learn about OpenFileDialog control in windows form article. Today, the same article i cover using WPF. The logics are same in all language but some presentation of the language are different Like previous article cover by windows form and this article present by xaml language. Lets take a simple example: In this example, we will pick the text file from computer and read this file by using TextBox.

<Grid>
        <TextBox x:Name="textBox" HorizontalAlignment="Left" Height="44" Margin="39,33,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="300"/>
        <Button x:Name="button" Content="Browse" HorizontalAlignment="Left" Margin="344,33,0,0" VerticalAlignment="Top" Width="130" Height="44"…