473,385 Members | 1,341 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,385 software developers and data experts.

DatagridView Disable some rows selection

greetings,

I have a datagrid view filled with some data, in that data some of the cells
are null and I would like to not let the user select the rows with null
values...

the problem is that the selection goes there when I click and then jump back
to last selected row... the correct behaviour would be stay on the last
selected row always until the user select a new valid row...

I desperate trying to solve this for weeks... please somebody give me a
hint...

Thanks in advance
Feb 26 '07 #1
2 19955
Does this help if you change the values for your grid and tables? I have this
code in the cell changed event

foreach (DataRow myDataRow in fixed1DataSet.Tables["Commands"].Rows)
{
s1Command = (myDataRow["CommandName"].ToString());
userUsed = (myDataRow["UseCode"].ToString()); //
get if user code is used for this comand
if (userUsed == "False")
{
scriptDataGridView[5,
e.RowIndex].ReadOnly = true; // disable user code cell
}
else
scriptDataGridView[5,
e.RowIndex].ReadOnly = false; // enable user code cell
}
}
"Diogo Alves - Software Developer" wrote:
greetings,

I have a datagrid view filled with some data, in that data some of the cells
are null and I would like to not let the user select the rows with null
values...

the problem is that the selection goes there when I click and then jump back
to last selected row... the correct behaviour would be stay on the last
selected row always until the user select a new valid row...

I desperate trying to solve this for weeks... please somebody give me a
hint...

Thanks in advance
Feb 26 '07 #2
Sorry Chris but that is not what I am looking for...

The table is always readonly...
I just don't want it to allow to select rows with null values...

if the user click a row with null... the grid is supposed to don't change
anything...
else if the user clicks on a row with all the info.. the selection go to
this row...

this should be a quite simple think to do but the datagrid does the
behaviour I described... selects the row with null and then go back to where
it should stay...

"Chris" wrote:
Does this help if you change the values for your grid and tables? I have this
code in the cell changed event

foreach (DataRow myDataRow in fixed1DataSet.Tables["Commands"].Rows)
{
s1Command = (myDataRow["CommandName"].ToString());
userUsed = (myDataRow["UseCode"].ToString()); //
get if user code is used for this comand
if (userUsed == "False")
{
scriptDataGridView[5,
e.RowIndex].ReadOnly = true; // disable user code cell
}
else
scriptDataGridView[5,
e.RowIndex].ReadOnly = false; // enable user code cell
}
}
"Diogo Alves - Software Developer" wrote:
greetings,

I have a datagrid view filled with some data, in that data some of the cells
are null and I would like to not let the user select the rows with null
values...

the problem is that the selection goes there when I click and then jump back
to last selected row... the correct behaviour would be stay on the last
selected row always until the user select a new valid row...

I desperate trying to solve this for weeks... please somebody give me a
hint...

Thanks in advance
Feb 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tony lock | last post by:
Has anybody found a way to disable a column in DataGridView i.e prevent it being selected. With DataGrid it was fairly easy to check on the column being entered and move the selection to the next...
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...
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...
2
by: Lennart | last post by:
Hi I have a DataGridView on a Form filled with data from a DataTable. When I Load this form I want to select a row in the DataGridView depending on a selected Primary Key index; How do I do...
2
by: shalakasan | last post by:
Hi, I am new to the forms world and have a silly doubt. I have form with a DataGridview and an "Add" button. When the user clicks on the add button, one row gets added to the datagrid. Now I...
0
by: Matt Pegg | last post by:
Hi all, I want be able to enable and disable navigation buttons when on the first or last row of a DataGridView object. I have a populated DataGridView and two buttons - "First Row" and...
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...
1
by: Paul Schwann | last post by:
Hi Group, I am using C# with .NET 2.0 and Visual Studio 2005. I have a GUI with a DataGridView (DGV) and a BindingSource for the data. The data are added programmatically, up to 5 rows per...
1
by: Aegixx | last post by:
Ok, extremely wierd situation here: (I'll post the code below, after the explanation) I've got a Windows application (.NET 3.5) that has a single Form with a DataGridView embedded. The user...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.