Set up DataGridView Properties of SelectionMode by FullRowSelect

In this way DataGridView Instead of selecting a field , Instead, choose a whole line

Set up DataGridView Properties of MultiSelect by false 
In this way DataGridView Cannot select multiple lines , You can only choose one line

To get the value of a column is to judge DataGridView Whether there are selected rows

if (dataGridView1.SelectedCells.Count != 0)
            {
                // Get the index of the selected row
                int intRow = dataGridView1.SelectedCells[0].RowIndex;

// Get the index of the column
                int intColumn = dataGridView1.SelectedCells[0].ColumnIndex;

// Get the value of the selected row or column
                string str = dataGridView1.CurrentRow.Cells[2].Value.ToString();
                MessageBox.Show(str);
            }

c# winform DataGridView Click to select an entire line , Only one can choose , You cannot select multiple lines , You can only select more related articles in one line

  1. WinForm DataGridView Delete according to the selected line

    private void btndel_Click(object sender, EventArgs e)        {            int count = 0;            ...

  2. WinForm DataGridView Delete... According to the selected check box

    Be careful : stay DataGridView Add a column (name:delete),ColumnType The attribute is :DataGridViewCheckBoxColumn,FlaseValue The attribute is :Flase,TureV ...

  3. winform Code : Associated form data update , Delete dataGridview One or more rows selected in the

    One . Associated form data update When the associated form data is modified , If a form is displayed for the overall data A, The other is to modify the form in detail B, from A Get into B, stay B Modify the data in , Then return A, At this time A The data of the form needs to be updated . I take the simplest approach , First of all, make sure that every ...

  4. hexo Adding the special effect of "little red heart" in click will make it impossible to double-click and select a whole line three times in a row

    List of articles Problem description solve Personal blog :https://mmmmmm.me Source code :https://github.com/dataiyangu/dataiyangu.github.io Problem description As the title , We ...

  5. WinForm in DataGridView Copy the selected cell content solution

    WinForm in DataGridView Select the cell content replication scheme with the mouse 1.CTR+C Shortcut key copy Premise : This control ClipboardCopyMode Property setting value is not Disable: 2. Mouse box selection , Custom code to achieve complex ...

  6. Click row , Select the radio box in the current line button

    demand : Click row , Select the radio box in the current line button. aspx page : <asp:Repeater ID="rptRecordList" runat="serve ...

  7. winform DataGridView Control development experience

    1. Not allow DataGridView Control automatically generates Columns Set up AutoGenerateColumns by false. dgTicket.AutoGenerateColumns = false; // The columns will be generated automatically ...

  8. C# winform DataGridView

    C# DataGridView Control to dynamically add new lines DataGridView Control is very practical in practical application , Especially when you need tables to display data . You can statically bind data sources , So it's automatically DataGridView Control to add the corresponding line . If ...

  9. Winform datagridview The relevant operation

    datagridview Showing the line number 2 Methods : Method 1 : The most common way to do it online is to use DataGridView Of RowPostPaint The incident happened in RowHeaderCell Draw line numbers in : privatevoiddat ...

Random recommendation

  1. seek 1...n The number with the most factors in

    Problem seek [1..N] The number with the most and the least prime factors in n,N Big enough . Solution Let any natural number n (n>2) decompose n=p1^k1 * p2^k2 * p3^k3 * ... * Pm^k ...

  2. bootbox.js

    bootbox: A pop-up plug-in , Just take a look at the examples on the official website :http://bootboxjs.com/examples.html For now, you should just call bootbox.js That's all right. , No, css The problem of 1. Have the most ...

  3. jquery.serialize() Function details

    jQuery - serialize() Method W3School The definition and usage are given : serialize() Method by serializing form values , establish URL Encoded text string . You can select one or more form elements ( such as i ...

  4. [USACO2003][poj2018]Best Cow Fences( A combination of numbers and shapes + Monotonous queue maintenance )

    http://poj.org/problem?id=2018 This is a divine topic …… See 04 The paper of the annual training team is written by Zhou Yuan , Look at this slope optimization dp It would be better to understand . analysis : So what we want is {S[j]-s[i-1]}/{j-(i ...

  5. Win7 Print Spooler Services shut down automatically

    about Win7 In terms of system , This problem is usually caused by installing the wrong print driver ,Win7 In order to protect other processes from interference , Automatically shut down the print service . The solution is : a> Delete unused printers . b> Make sure you have installed it correctly ...

  6. suse System uninstall database instance

    1. Stop database : 2. Execute the following command : find $ORACLE_BASE/* -name '*[Tt][Ee][Ss][Tt]*'  among TEST Is the instance name of the database : Delete existing files : 3. Delete /etc ...

  7. Python Automation operation and maintenance 26、Web Framework essence 、MVC And MTV

    One .Web Framework essence as everyone knows , For all Web application , In essence, it's a socket Server side , The user's browser is actually a socket client . #!/usr/bin/env python #coding:ut ...

  8. Replace IMG

    <?php $str = '<img src="http://img01.feiniu.com/images/show/detail/image/20141031/9b3bbc3 ...

  9. CodeForces 629C Famil Door and Brackets

    DP. specific working means :dp[i][j] The length is i Bracket string of , The prefix and ( The left bracket indicates 1, The right bracket indicates -1) by j There are several of them . State transitions are easy to get :dp[i][j]=dp[i - 1][j + 1]+dp[i ...

  10. PHP Design pattern Overview

    PHP Design pattern Overview Design patterns (Design pattern) It's a set that's been used over and over again . Most people know that . Catalogued . Summary of code design experience . Design patterns are used for reusable code . Make code easier to understand . Ensure code reliability . ...