PC Review


Reply
Thread Tools Rate Thread

DataGridViewComboBox selectively hide arrow

 
 
Paul E
Guest
Posts: n/a
 
      11th Jan 2007
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
 
 
 
 
RobinS
Guest
Posts: n/a
 
      12th Jan 2007
Why would you put a combobox in the grid if you don't want
the user to use it?

Robin S.
-----------------------
"Paul E" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
 
Paul E
Guest
Posts: n/a
 
      12th Jan 2007
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
 
AnikSol
Guest
Posts: n/a
 
      12th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Inactive Icons arrow... ME Windows XP General 0 29th Oct 2008 02:43 AM
Selectively hide Systray icons possible ? Mark O'Reilly Windows XP Help 3 17th Jan 2007 08:56 AM
Selectively hide Systray icons possible ? Mark O'Reilly Windows XP General 1 16th Jan 2007 09:01 PM
Is it possible to selectively print or hide pages based on a linked field? bob Microsoft Word New Users 1 16th Nov 2005 06:29 AM
Macro to selectively hide columns stanleysi Microsoft Excel Discussion 2 29th Apr 2004 01:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:50 AM.