Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

DataGridViewComboBox selectively hide arrow

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul E - 11 Jan 2007 21:28 GMT
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::DataGridView^  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.
RobinS - 12 Jan 2007 06:39 GMT
Why would you put a combobox in the grid if you don't want
the user to use it?

Robin S.
-----------------------
>I have a column on my DataGridView that is of the type
> DataGridViewComboBoxColumn. On some of my rows, I want to keep the
[quoted text clipped - 25 lines]
> regular edit cell. I'm not sure how to do that, or if that would just
> confuse the control altogether.
Paul E - 12 Jan 2007 15:29 GMT
> 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.
AnikSol - 12 Jan 2007 16:38 GMT
set the combobox column display style to nothing, for the arrows to vanish
and at the same time make those cells read only.

>> Why would you put a combobox in the grid if you don't want
>> the user to use it?
[quoted text clipped - 16 lines]
> 5,6,12, and 15, I want to display the combobox for the user to
> manipulate.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.