PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms DataGridViewComboBox selectively hide arrow

Reply

DataGridViewComboBox selectively hide arrow

 
Thread Tools Rate Thread
Old 11-01-2007, 09:28 PM   #1
Paul E
Guest
 
Posts: n/a
Default DataGridViewComboBox selectively hide arrow


I have a column on my DataGridView that is of the type
DataGridViewComboBoxColumn. On some of my rows, I want to keep the user
from changing the value in that field.

What I'm doing now is, as soon as I populate my rows, I run through
each row something like this:

private: System::Windows::Forms:ataGridView^ Fields;
...
#define COMBO_COL 3

for (int i = 0; i < Fields->RowCount; ++i)
{
if (it shouldn't be changed)
{
Fields->Rows[i]->Cells[COMBO_COL]->ReadOnly = true;
}
}

That works, but it both looks ugly and doesn't give the user a clue
about why the combo box's arrow doesn't do anything.

Ideally, what I'd like to do is hide the arrow altogether for those
rows. Does anyone have any ideas about how to do that?

One thought is that I could change the cell type on the fly to a
regular edit cell. I'm not sure how to do that, or if that would just
confuse the control altogether.

  Reply With Quote
Old 12-01-2007, 06:39 AM   #2
RobinS
Guest
 
Posts: n/a
Default Re: DataGridViewComboBox selectively hide arrow

Why would you put a combobox in the grid if you don't want
the user to use it?

Robin S.
-----------------------
"Paul E" <prosen@inovasolutions.com> wrote in message
news:1168550891.585193.267100@i39g2000hsf.googlegroups.com...
>I have a column on my DataGridView that is of the type
> DataGridViewComboBoxColumn. On some of my rows, I want to keep the
> user
> from changing the value in that field.
>
> What I'm doing now is, as soon as I populate my rows, I run through
> each row something like this:
>
> private: System::Windows::Forms:ataGridView^ Fields;
> ...
> #define COMBO_COL 3
>
> for (int i = 0; i < Fields->RowCount; ++i)
> {
> if (it shouldn't be changed)
> {
> Fields->Rows[i]->Cells[COMBO_COL]->ReadOnly = true;
> }
> }
>
> That works, but it both looks ugly and doesn't give the user a clue
> about why the combo box's arrow doesn't do anything.
>
> Ideally, what I'd like to do is hide the arrow altogether for those
> rows. Does anyone have any ideas about how to do that?
>
> One thought is that I could change the cell type on the fly to a
> regular edit cell. I'm not sure how to do that, or if that would just
> confuse the control altogether.
>



  Reply With Quote
Old 12-01-2007, 03:29 PM   #3
Paul E
Guest
 
Posts: n/a
Default Re: DataGridViewComboBox selectively hide arrow

RobinS wrote:
> Why would you put a combobox in the grid if you don't want
> the user to use it?


I have about 20 rows on my grid. Depending on the data that is in a
particular row, the data in the combobox column may not be changable.
As it turns out, only around a quarter of the rows should allow the
user to change that column. If the combobox's arrow only appeared on
those 4 or so cells, then they would pop out to the user and be
obvious.

To be more concrete, I have 20 rows in my grid. I don't allow the user
to change the data in the first column. It is an edit type column. I do
allow the user to change the data in the second column. It is also an
edit type column. In the third column, I only want to allow the user to
change the data in rows #5, 6,12, and 15. It is a combobox column.

In all the other rows, that is (1,2,3,4,7,8...) I would like to display
the data in column 3 as if it were an edit type column, but in rows
5,6,12, and 15, I want to display the combobox for the user to
manipulate.

  Reply With Quote
Old 12-01-2007, 04:38 PM   #4
AnikSol
Guest
 
Posts: n/a
Default Re: DataGridViewComboBox selectively hide arrow

set the combobox column display style to nothing, for the arrows to vanish
and at the same time make those cells read only.




"Paul E" <prosen@inovasolutions.com> wrote in message
news:1168615765.748788.36390@s34g2000cwa.googlegroups.com...
> RobinS wrote:
>> Why would you put a combobox in the grid if you don't want
>> the user to use it?

>
> I have about 20 rows on my grid. Depending on the data that is in a
> particular row, the data in the combobox column may not be changable.
> As it turns out, only around a quarter of the rows should allow the
> user to change that column. If the combobox's arrow only appeared on
> those 4 or so cells, then they would pop out to the user and be
> obvious.
>
> To be more concrete, I have 20 rows in my grid. I don't allow the user
> to change the data in the first column. It is an edit type column. I do
> allow the user to change the data in the second column. It is also an
> edit type column. In the third column, I only want to allow the user to
> change the data in rows #5, 6,12, and 15. It is a combobox column.
>
> In all the other rows, that is (1,2,3,4,7,8...) I would like to display
> the data in column 3 as if it were an edit type column, but in rows
> 5,6,12, and 15, I want to display the combobox for the user to
> manipulate.
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off