background preloader

C# tutorial

Facebook Twitter

C# Tutorial: Create a Glossy Button [Custom Controls] ListView in C# ListView in C# A ListView control provides an interface to display a list of items using different views including text, small images, and large images. In this tutorial, we will learn how to create a ListView control. We will also see how to create multiple views of ListView items. This article also covers most of the properties and methods of the ListView control. Creating a ListView There are two approaches to create a ListView control in Windows Forms. Design-time In our first approach, we are going to create a ListView control at design-time using the Forms designer. To create a ListView control at design-time, we simply drag and drop a ListView control from the Toolbox onto a Form in Visual Studio.

Figure 1 Run-time The ListView class represents a ListView control in Windows Forms. The first step to create a dynamic ListView is to create an instance of the ListView class. ListView ListView1 = new ListView(); In the next step, you may set the properties of the ListView control. Figure 2. Visual Studio 2012 Keyboard Shortcuts. Here are some extremely helpful keyboard shortcut keys for Visual Studio 2012. You probably know most, but some you won’t know. For instance, did you know that Ctrl+. is the same as Sift+Alt+F10? These shortcuts assume you have you environment configured for C# development. If you have another configuration, like web, these shortcuts may not work.

To use, hold down the control key and hit the key combination. Go to Definition (F12) Navigate to the definition of the method or variable. Find all References (Shift + F12) Update References/ Add Using Statement (Ctrl +. or Shift +Alt +F10) I’m referring to the underline that appears under a variable to perform an action like add a using statement, or refacter a method or class name. List Members (Ctrl +J or Ctrl +K, L) Displays the autocomplete list for classes, methods, or properties. List Parameter Info (Ctrl +Shift +Space or Ctrl +K +P) Lists the parameters for a method. Code Bookmarks Use these to bookmark a line of code.

A Detailed Data Binding Tutorial. Download source code - 29.8 KB (This is a Visual Studio 2008 project. It contains two "Master-Detail" samples from this article.) Introduction The documentation for Windows Forms data binding is pretty sparse. How does it work, exactly? How much can you do with it? I believe "data binding" has traditionally referred to automatic synchronization between controls and database rows or tables. System.Windows.Forms.BindingSource is new in the .NET Framework 2.0. Data binding can use Reflection, so you're not limited to database tables and rows in ADO.NET DataSets; rather, almost any object that has properties will work. This is not a tutorial for ADO.NET/DataSets or DataGridView, but see Related Articles. Note: In this article, I assume you are proficient in C# (and maybe ADO.NET), but you know nothing about data binding. Disclaimer: I talk a little bit about .NET Compact Framework support for data binding, but I don't know whether everything described here is possible on that platform.

Contents. DataGrid in WPF. This article shows you how to create and use a DataGrid control in WPF and XAML. Note: This article is written using Visual Studio 2010 and .NET Framework 4.0. Introduction DataGrid element represents WPF DataGrid control in XAML. When you drag and drop a DataGrid control from Toolbox to your designer, position the control, this action adds following code to XAML. The Width and Height properties represent the width and the height of a DataGrid. The Name property represents the name of the control, which is a unique identifier of a control. The Margin property sets the margin of placement of DataGrid on the window. Listing 1 Figure 1 shows Toolbox and XAML code preview after a DataGrid is added to a page. Figure 1 Data Binding The ItemSource property of DataGrid is the key to data binding.

In this example, we will create a collection of objects and bind it to a DataGrid control. First, we are going to add a class to the project. Listing 2 Listing 3 McDataGrid.ItemsSource = LoadCollectionData(); WPF DataGrid Practical Examples. Download source code - 65.44 KB Contents Introduction A DataGrid is a user interface component for displaying tabular data to the user, typically providing sorting and editing functionality, among others.

DataGrids have been the work-horse of various frameworks such as ASP.NET (GridView) and Windows Forms (DataGridView). However, DataGrids in WPF are rather conspicuous in their absence! Fortunately, the absence of this control has not hampered the popularity of WPF. The versatility of the ListView control allows very flexible read-only DataGrid functionality. Eventually, in August 2008, Microsoft released its DataGrid CTP (Community Technology Preview - a public beta) to CodePlex to coincide with the release of the .NET Framework 3.5 SP1 and Visual Studio 2008 SP1. More recently, on October 22 2008, DataGrid v1 was released. Article Overview I cannot, of course, cover everything. Installing the WPF Toolkit The WPF DataGrid is part of the WPF Toolkit.

Install the .NET Framework 3.5 SP1. GridView in WPF. If you are looking for a GridView control in WPF, you will be disappointed. WPF does not have a GridView control. But the good news is you can achieve GridView like functionality with a ListView control available in WPF. If you have not used a ListView control in WPF, I recommend you read my ListView in WPF article before this article. The View property is used to provide a GridView layout and design in a ListView control. The View property of ListView is a type of ViewBase class that supports two view types - GridView and a custom view.

A GridView is used for arranging data in columns and adding layout and design support to a ListView. The following code snippet sets the View property of a ListView to GridView mode. A GridView is used as a supplement control to a ListView to provide style and layout. Creating a GridView The GridView element in XAML represents a GridView at design-time. The code listed in Listing 1 creates a GridView control and adds four columns to it. Listing 1 Figure 1. Getting Started with Windows Presentation Foundation. This walkthrough provides an introduction to the development of a Windows Presentation Foundation (WPF) application that includes the elements that are common to most WPF applications: Extensible Application Markup Language (XAML) markup, code-behind, application definitions, controls, layout, data binding, and styles.

This walkthrough guides you through the development of a simple WPF application using the following steps. Defining XAML to design the appearance of the application's user interface (UI).Writing code to build the application's behavior.Creating an application definition to manage the application.Adding controls and creating the layout to compose the application UI.Creating styles to create a consistent appearance throughout an application's UI.Binding the UI to data to both populate the UI from data and keep the data and UI synchronized. You need the following components to complete this walkthrough: Visual Studio 2010 In this section, you build and run the application. Mastering Debugging in Visual Studio 2010 - A Beginner's Guide. Table of Contents Introduction In the software development life cycle, testing and defect fixing take more time than actually code writing.

In general, debugging is a process of finding out defects in the program and fixing them. Defect fixing comes after the debugging, or you can say they are co-related. Now how to debug the code? How to Start? You can start debugging from the Debug menu of VS IDE. Figure: Start Debugging There is another way to start the debugging by "Attach Process". We generally start debugging any application just by putting breakpoint on code where we think the problem may occur. Breakpoints Breakpoint is used to notify debugger where and when to pause the execution of program. Figure: Set Breakpoint Debugging with Breakpoints You have already set a breakpoint in your code where you want to pause the execution. Now you have several commands available in break mode, using which you can proceed for further debugging. Figure: Breakpoint Toolbar Step Over Step Into Step Out. .net - How can I read all files from directory c# C# Tutorials, Windows Forms Tutorials, GDI+ Tutiroals, .NET Tutorials.

C# School - Multithreading - Lesson #14 - Page 1. Development for Beginners | Tier One: Windows Development | MSDN.