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...