Results 1 to 7 of 7

Thread: DataGridView Entire Row Selection

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2011
    Posts
    33

    DataGridView Entire Row Selection

    Hi, I want to know if it is possible to click in one cell, and the entire row be selected.

    Thanks =D

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DataGridView Entire Row Selection

    The first thing you should do with a control is open the Properties window and see what properties it has. Your answer is in there.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2011
    Posts
    33

    Re: DataGridView Entire Row Selection

    Quote Originally Posted by jmcilhinney View Post
    The first thing you should do with a control is open the Properties window and see what properties it has. Your answer is in there.
    I tried but nothing happened, but thanks anyway =D

    I were searching in the forum and I found this which solved my problem =D

    Thanks.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DataGridView Entire Row Selection

    Quote Originally Posted by ikartz View Post
    I tried but nothing happened
    Tried what? The SelectionMode property appears in the properties window and you should be setting it there, as was my implication, rather than in code.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2011
    Posts
    33

    Re: DataGridView Entire Row Selection

    Quote Originally Posted by jmcilhinney View Post
    Tried what? The SelectionMode property appears in the properties window and you should be setting it there, as was my implication, rather than in code.
    believe me, I changed it to 'FullRowSelection' but I could only select cell at cell
    that's why I asked for help here =)

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DataGridView Entire Row Selection

    Quote Originally Posted by ikartz View Post
    believe me, I changed it to 'FullRowSelection' but I could only select cell at cell
    that's why I asked for help here =)
    That's probably something that you should have included in your first post, e.g.
    I have already set the SelectionMode property to FullRowSelect in the Properties window but it doesn't seem to work.
    That said, if you really did set SelectionMode to FullRowSelect and it didn;t work then something is broken in your project or on your system. That is the one and only way to achieve your aim and whether you write code or do it in the designer should make no difference, because doing it in the designer simply generates code anyway. I just tested it out myself to make sure, even though I already knew that was the case. Here's the designer code for a form with nothing but a DGV added and that property set:
    Code:
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class Form1
        Inherits System.Windows.Forms.Form
    
        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.DataGridView1 = New System.Windows.Forms.DataGridView()
            CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'DataGridView1
            '
            Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
            Me.DataGridView1.Dock = System.Windows.Forms.DockStyle.Fill
            Me.DataGridView1.Location = New System.Drawing.Point(0, 0)
            Me.DataGridView1.Name = "DataGridView1"
            Me.DataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect
            Me.DataGridView1.Size = New System.Drawing.Size(284, 262)
            Me.DataGridView1.TabIndex = 0
            '
            'Form1
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(284, 262)
            Me.Controls.Add(Me.DataGridView1)
            Me.Name = "Form1"
            Me.Text = "Form1"
            CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
    
        End Sub
        Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView
    
    End Class
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Member
    Join Date
    Jul 2011
    Posts
    33

    Re: DataGridView Entire Row Selection

    ok =)
    thanks and sorry about that =)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width