Skip to main content

Posts

Get Selected Rows in DataGridView

Here is the simple trick to get selected value in DataGridView in C# object value = dataGridView1.Rows[e.Cell.RowIndex].Cells[3].FormattedValue;  object value1 = dataGridView1.Rows[e.Cell.RowIndex].Cells[4].FormattedValue;  object GSTPercentage = dataGridView1.Rows[e.Cell.RowIndex].Cells[5].FormattedValue;    if (value == "" || value1 == "" || GSTPercentage == "")        return;   double result = Convert.ToDouble(value);   double result1 = Convert.ToDouble(value1);   double resultGST = Convert.ToDouble(GSTPercentage);    double NetValue = (result * result1) * resultGST;    dataGridView1.Rows[e.Cell.RowIndex].Cells[6].Value = Convert.ToString(NetValue);

Multicast Delegates :: Advance : C# programming for c++ programmers

Defination: A Multicast delegate is a delegate that has references to more than one function. When you call a multicast delegate, all the functions the delegate is pointing to, are invoked. Example 1: using System; namespace demo {     public delegate void demoDelegate();          public class demoSample     {         static void Main()         {             demoDelegate del1 = new demoDelegate(demoMethodOne);             demoDelegate del2 = new demoDelegate(demoMethodTwo);             demoDelegate del3 = new demoDelegate(demoMethodThree);                          demoDelegate del4 = del1 + del2 + del3 - del3;                          del4();  // del4 ...

Delegates :: Advance : C# programming for c++ programmers

1. Definition:  A Delegate is a type safe function pointers and it  hold   reference (i.e. Pointer) to a function.  Delegates are like reference types like classes and interfaces. Unlike structures are value type. The reasont o say delegate as type safe because  delegate must match the signature of the function, the delegate points to, otherwise you get a compiler error. Syntax:  Same a member function with a keyword delegate public delegate void func(string param); class demo {     public static void Main()     {         // ignature must match the signature of the delegate         func del = new func(method);         // Invoke the delegate, which will invoke the method         del("Hello from Delegte");     }     public static void method(string param)     {         Co...

indexers :: Advance : C# programming for c++ programmers

1. Where are indexers used in .NET : To store or retrieve data from session state or application state variables, we make use indexers. Session["sessiondata"] = "sessiondata"; 2. Defination : An indexer allows an object to be indexed such as an array Syntax : A one or multi param indexer has the following syntax: element-type this[int index, ..] {    // The get accessor.    get    {       // return the value specified by index    }        // The set accessor.    set    {       // set the value specified by index    } } Points to remember: 1. We then created an indexer using "this" keyword. This indexer takes employeeId as parameter and returns employee name. public string this[int employeeId] 2. Just like properties indexers have get and set accessors. 3. Indexers can also be overloaded.  using System; using System.Collectio...

Reflection::Advance : C# programming for c++ programmers

Reflection Reflection is the ability of inspecting an assemblie's metadata at runtime.   It is used to find all types in an assembly and/or dynamically invoke methods in an assembly.  This includes information about the type, properties, methods, and events of an object. With Reflection, we can dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties.There are several uses of reflection. 1. When you drag and drop a button on a win forms or an asp.net application. The properties window uses reflection to show all the properties of the Button class. So,reflection is extensivley used by IDE or a UI designers. 2. Late binding can be achieved by using reflection. You can use reflection to dynamically create an instance of a type, about which we don't have any information at compile time. So, reflection enables you to use code that is not available a...

Attributes::Advance : C# programming for c++ programmers

1. C# - Attributes: Attributes allow you to add declarative information to your programs. This information can then be queried at runtime using reflection. Atrributes can be applied on class, methods, assemblies etc. You You can add declarative information to a program by using an attribute. A declarative tag is depicted by square ([ ]) brackets placed above the element it is used for. A few pre-defined attributes with in the .NET framework. Obsolete - Marks types and type members outdated WebMethod - To expose a method as an XML Web service method Serializable - Indicates that a class can be serialized Predefined Types Of Atrributes 1). AttributeUsage 2). Conditional 3). Obsolete 1). AttributeUsage:       It specifies the types of items to which the attribute can be applied.       Syntax for specifying this attribute is as follows:       [AttributeUsage(         validon,   //The parame...