473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

dataGridView Selection?

15
Is it possible and how to disable selection of 1'st row in dataGridView.

I made it select some other row, but even so when u try to move with arrows on keyboard it'll select 2'nd row(cause 1'st row was selected initially and you can see it's selected on RowHeader-1'st/Left Column)

This is my code for selecting row:

Expand|Select|Wrap|Line Numbers
  1. dataGridView1.ClearSelection();
  2. dataGridView1.Rows[BoPrI].Selected = true;
  3. dataGridView1.FirstDisplayedScrollingRowIndex = BoPrI;
BoPrI is int variable that has Index Value
May 3 '12 #1

✓ answered by RhysW

oh i see, you mean how to make it show the little black arrow pointing to the actual line thats selected?

wow what version of visual studio are you using btw?

these quotes from the link at the bottom of this answer, though the logic should help you now that i know what youre on about XD i honestly couldnt figure out what you mean but the picture helped :L they speak a thousand words you know, but i would love to see you make this into a movie just for me ;)

Expand|Select|Wrap|Line Numbers
  1. The row gets selected, (the cells in the row are highlighted), but the little black arrow in the column to the left of the data stays at the previously selected row.
  2.  
Expand|Select|Wrap|Line Numbers
  1. I've worked it out.
  2. I need to make the row the current row.
  3. CurrentRow is readonly, but setting the current cell has the desired effect.
  4.  
http://social.msdn.microsoft.com/For...-4f3fdd34517e/

6 5396
RhysW
70
write a bit of code that is fired everytime the selected row is changed, make this code check if row 0 is selected, if it is, set selected row to row 1.
May 4 '12 #2
Djiber
15
Hmmm, now I'm not sure if you didn't understand me or I don't understand you :P

This ^^ is code that fires everytime selected row is changed cause it's a part of refresh function and now like I've said it does work it selects the row I wish it to select, it focus it so if it's in the middle of the database it'll go to it and select it so it scrolls to it and everything.

On Form I have edit button that when you click it will edit that selected row, with pressing enter you will edit selected row and now we came to but...

When you click Down Arrow on Keyboard it acts like 1'st row was selected and it selects 2'nd row. (If you have visible Row Header you can see that after refresh there's an arrow tag on 1'st row even so some other row is/was selected and by selected I mean it's whole blue and any action that I send to selected row will apply to it and not to 1'st row)
May 4 '12 #3
RhysW
70
so whats the problem? you said you dont want it to select the frist row, then explained that it started with the second row anyway, im not seeing what the problem is :S
May 4 '12 #4
Djiber
15
http://desmond.imageshack.us/Himg857...pg&res=landing



Red/Selected Row is row that I've selected, edited, then refreshed grid and reselect it (When I click on "Promjeni" button/Edit button I can edit that row and it'll reselect it again)

Blue/Phantom Selected Row is row that gets autoselected (You can notice the arrow/triangle on the Row Header) If I click Down arrow DataGridView will act like 1'st row was selected and it'll select 2'nd row/If I click Up arrow nothing will happen cause 1'st row is selected.

How to stop autoselection of Blue row or make it autoselect my reselected Red row(I want that Arrow/Triangle from Blue row to be on my Red row) :P

Hope picture helped to understand my problem, if not I'm gonna make Power Point Presentation or Movie :P
May 4 '12 #5
RhysW
70
oh i see, you mean how to make it show the little black arrow pointing to the actual line thats selected?

wow what version of visual studio are you using btw?

these quotes from the link at the bottom of this answer, though the logic should help you now that i know what youre on about XD i honestly couldnt figure out what you mean but the picture helped :L they speak a thousand words you know, but i would love to see you make this into a movie just for me ;)

Expand|Select|Wrap|Line Numbers
  1. The row gets selected, (the cells in the row are highlighted), but the little black arrow in the column to the left of the data stays at the previously selected row.
  2.  
Expand|Select|Wrap|Line Numbers
  1. I've worked it out.
  2. I need to make the row the current row.
  3. CurrentRow is readonly, but setting the current cell has the desired effect.
  4.  
http://social.msdn.microsoft.com/For...-4f3fdd34517e/
May 4 '12 #6
Djiber
15
I'm using Visual C# 2010 Express

SRY I didn't reply sooner, but didn't have access to internet over the weekend.

Yes I've thought picture may help, cause it's hard to explain it on my language and even harder on English, I don't speak it that often :P

I'm gonna check that thread, try to implement it and check does it solve my problem.

Thanks for the reference

Edit:
Yap setting current cell property worked like a charm:

Expand|Select|Wrap|Line Numbers
  1. dataGridView1.CurrentCell = dataGridView1.Rows[BoPrI].Cells[0];
Thanks again for the help
May 7 '12 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michel Lapointe | last post by:
Hello, I would like to know if there is an event for the Datagridview control that is trigger before the selection change and is cancelable. I'm currently using the SelectionChanged event...
4
by: steve | last post by:
Hi All I have a datagridview bound to a datatable Due to the use of touch screens I need to be able to scroll the grid in code in response to a button click i.e each button touch (click) will...
0
by: Paul Cheetham | last post by:
Hi, I have a DataGridView Control, which I am databinding at run-time. When the data is loaded, the first row in the grid gets selected, and the selectionChanged event gets fired. I want the...
6
by: George | last post by:
Hi, I have been encountering a refresh problem with DataGridView, which is bound to a DataTable. When I make updates (Add, Delete, update) to the DataGridView, everything flow nicely to...
0
by: Paul Cheetham | last post by:
Hi, I have a DataGridView control, where I am setting its Datasource property to a datatable. The DataGridView has it's MultiSelect property set to false I also have a handler for the...
2
by: martin1 | last post by:
Hi, All, The datagridview auto-select first column first row data and the slected cell background color is blue, so how to turn off the select? or how to change selected cell backcolor to white?...
0
by: DBC User | last post by:
I have a datagridview and there are 4 coulmns, the user could do sort on any of the columns. After doing sorting. The user could do refresh the datagridview and get another set of data. But when I...
0
by: nareshg1 | last post by:
Hi all, I am trying to display four datagridviews which has fixed size. I am displaying these grids on panel, It is like template. All grids scroll bar are disable. When i scroll vertically...
2
by: colin | last post by:
Hi, I need to tell how many rows are visible on the screen, in my DataGridView control so that I can ensure my newly selected row is visible without doing any unecessry scrolling, I thought...
6
by: hzgt9b | last post by:
Using VS2005, VB.NET, I have a windows app with a DataGridView (lets call it DGV). At some point in the life of my app I want to clear the selection of the currently selected row...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.