Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Turning off and on blue highlight bar on selected row of datagridview

Posted on 2011-03-06
4
Medium Priority
?
1,288 Views
Last Modified: 2012-08-13
I have a datagridview that I want to look like a cash register tape.  So I dont want the blue highlight bar over any of the rows.  I was able to get rid of it with the following code,
 Private Sub dgItems_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgItems.SelectionChanged
        If dgItems.SelectedRows.Count > 0 Then
            dgItems.SelectedRows(0).Selected = False
        End If
    End Sub

However when someone clicks on a row of the datagridview I want to turn it back on so we can seel the selected item.  Tried a few things in the cell.click and cellcontent.click, but to no avail.  Thanks in advance for the help

Private Sub dgItems_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgItems.CellClick
        Dim i As Integer = e.RowIndex
        dgItems.Rows(i).Selected = True
    End Sub
0
Comment
Question by:mgmhicks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 35047074
have you tried setting the SelectionMode to FullRowSelect? Do this in the properties of the datagridview and see what it throw up!
0
 

Author Comment

by:mgmhicks
ID: 35047199
Yes, it is set to fullrowselected.  

0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 35047307
Hi...You may play with the DefaultCellStyle..
When The datagridview is loaded set the Selection BackColor and SelectionForeColor the same as the DadatagridView's Color's
Then In the Cell Click Event change these Colors and "Highlight" the selected Row..
Hope It Helps..
0
 
LVL 17

Accepted Solution

by:
nepaluz earned 2000 total points
ID: 35047369
set the focus to another item on the form (either during Form_Load or after populating / databinding  the grid)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question