We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Disable ComboBox dropdown in readonly columns.

Thread ID:

Created:

Updated:

Platform:

Replies:

6404 Aug 12,2003 02:38 AM UTC Oct 18,2016 08:07 AM UTC WinForms 3
loading
Tags: GridControl
Markus Kraft
Asked On August 12, 2003 02:38 AM UTC

Hi, i have 3 questions: 1. is it possible to lock the combobox dropdown in readonly gridboundcolumns ? 2. why is it possible to start editing in readonly textboxes ? 3. can i change the cell textcolor or backcolor for editmode(standart is lightgrey)?

Administrator [Syncfusion]
Replied On August 12, 2003 05:24 AM UTC

1) The simplest way to prevent the dropdown from dropping is to set its cell's style.Enabled = false. If you do this, then the cell cannot be clicked or become current. If you want your cell to be able to be the CurrentCell, but just not drop the combobox, then handle the CurrentCellShowingDropDown and set e.Cancel = true if grid.CurrentCell.RowIndex and grid.CurrentCell.ColIndex point to this combobox cell. 2) In the .NET framework (say a standard TextBox), being ReadOnly does not prevent the control from accepting input focus and displaying a cursor. If you do not want to see the edit cursor, set the style.CellType = "Static" when you set teh style.ReadOnly = true. 3) See the code snippet in this forum thread. It changes the TextColor based on whether the cell is editing or not. You can also change the BackColor by adding e.Style.BackColor = ???? lines.

Guilherme de Alvarenga
Replied On October 17, 2016 04:56 PM UTC

Please show an example

Piruthiviraj Malaimelraj [Syncfusion]
Replied On October 18, 2016 08:07 AM UTC

Hi Guilherme, 
 
Thanks for your interest in Syncfusion products. 
 
Query 
Response 
 
 
 
 
 
Is it possible to lock the combobox dropdown in readonly gridboundcolumns ?  
To avoid the dropdown showing when the grid is in non-editable mode, you can use anyone of the following suggestions, 
 
Suggestion 1: 
The CurrentCellShowingDropDown event of grid can be used to restrict the dropdown showing in non-editable mode. Please make use of the below code, 
 
Code example: 
this.gridControl1.CurrentCellShowingDropDown += gridControl1_CurrentCellShowingDropDown; 
 
//Disable the dropdown showing in NonEditable mode. 
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e) 
{ 
    if (this.gridControl1.BrowseOnly) 
        e.Cancel = true; 
} 
 
Suggestion 2: 
You can set the Enabled property to false for that combobox column, to lock the dropdown. Please make use of the below code, 
 
Code example: 
this.gridControl1.ColStyles[1].Enabled = false; 
Why is it possible to start editing in readonly textboxes ? 
In the .NET framework (say a standard TextBox), being ReadOnly does not prevent the control from accepting input focus and displaying a cursor. If you do not want to see the edit cursor, you can use BrowseOnly property instead of ReadOnly.  
 
Code example 
this.gridControl1.BrowseOnly = true; 
 
 
 
 
 
 
 
 
Can i change the cell textcolor or backcolor for editmode? 
In order to change the cell text color and back color when current cell is in edit mode, QueryCellInfo event of grid can be used. Please make use of the below code, 
 
Code example 
this.gridControl1.BrowseOnly = false; 
this.gridControl1.QueryCellInfo += gridControl1_QueryCellInfo; 
 
//Change the Cell text color and back color in edit mode. 
void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
{ 
    bool hasCurrentCell = this.gridControl1.CurrentCell.HasCurrentCellAt(e.RowIndex, e.ColIndex); 
    bool isEditMode = this.gridControl1.CurrentCell.IsEditing; 
    if (hasCurrentCell && isEditMode) 
    { 
        e.Style.BackColor = Color.Yellow; 
        e.Style.TextColor = Color.Red; 
    } 
} 
 
Sample link 
 
Regards, 
Piruthiviraj 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;