DatagridView Disable some rows selection

G

Guest

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
 
G

Guest

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
}
}
 
G

Guest

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 said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top