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: - dataGridView1.ClearSelection();
-
dataGridView1.Rows[BoPrI].Selected = true;
-
dataGridView1.FirstDisplayedScrollingRowIndex = BoPrI;
BoPrI is int variable that has Index Value
6 5408
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.
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)
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
http://desmond.imageshack.us/Himg857...pg&res=landing ![](/images/imgserve.php?url=http://imageshack.us/photo/my-images/857/problemk.jpg)
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
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 ;) - 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.
-
-
I've worked it out.
-
I need to make the row the current row.
-
CurrentRow is readonly, but setting the current cell has the desired effect.
-
http://social.msdn.microsoft.com/For...-4f3fdd34517e/
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: - dataGridView1.CurrentCell = dataGridView1.Rows[BoPrI].Cells[0];
Thanks again for the help
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 (using Full Row Select),
but this event is trigger only after the selection changed is completed and
therefore is non cancelable unless you keep the previous selection in a
variable and rechange the selection, which is painful.
|
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 move the selection up 1 row
How do I do that
|
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 datagrid to have nothing selected by default, until a row is
selected by the user.
Is this possible?
|
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 DataTable. No problem here.
However, when I add data (programatically) to the DataTable, the
DataGridView does not refresh right away. If I minimize and show my form,
|
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 SelectionChanged event.
When I load the data, I set the DataSource property, and then call
ClearSelection() to make sure there are no selected rows.
| |
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?
Thanks
|
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 display the
another set of data the sorting selection is lost. Is there a way to
presist the user selection on the data grid easily?
Thanks.
|
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 by using panel scroll bar and try to select any row from grid, it automatically scroll up and select all the rows from that row.
|
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 RowCount would give me this :-
Summary:
Gets or sets the number of rows displayed in the
System.Windows.Forms.DataGridView.
|
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 (Multiselect=false) from DGV - to do that I
tried this:
DGV.ClearSelection()
Cosmetically this appears to work but it appears that the DGV still
stores the index value of the selected row. If the 1st row I click on
after executing ClearSelection() is the row...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |