PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
DataGridViewComboBox selectively hide arrow
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
DataGridViewComboBox selectively hide arrow
![]() |
DataGridViewComboBox selectively hide arrow |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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. > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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. |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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. > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 
ataGridView^ Fields;
