Ticket Q443609
Visible to All Users

How to Indetify a grid cell is readly only or not?

created 12 years ago

I have a gridview form.
Some guy set certain grid cell readonly, light gray color.
My question is:
How can I identify the row cell style directly?

Comments (2)
Alex Skorkin (DevExpress) 12 years ago

    Hi Zheng,
    Thank you for your inquiry. From your message, it is not clear to me what technology you are using (WinForms, WPF, ASP.NET, Silverlight). Would you please clarify this?

      Thanks for your response.
      WinForms

      Answers

      created 12 years ago (modified 12 years ago)

      Hi,
      Thank you for contacting us.
      Appearance settings that are changed in the GridView.RowCellStyle event handler are not stored as cell properties.
      As far as I understand, you have implemented the approach illustrated in the How to customize the Look-And-Feel of my grid cells KB article.
      I.e., you have defined some rules that determine whether or not a current cell will be painted with the light-gray color, or whether or not an editor will be shown in the current cell.
      From this point of view, I suggest you use the same rules to determine whether or not the current cell is read-only.
      I have created a simple sample that illustrates my interpretation of your scenario. Please find it in the attachment.
      If this is not your case, please provide us with your sample or modify mine so it illustrates your scenario and final goal. We will do our best to help you.

        Show previous comments (1)
        DevExpress Support Team 12 years ago

          Hi,
          If you define custom rules that determine whether or not a current sell is read-only in the GridView.ShowingEditor event, you can check a specific cell state using the GridView.CanShowEditor property value.
          But this property gets a value indicating whether a View can activate an editor for a focused cell. Thus, you need to focus a specific cell before using this property. Look at the following code based on the sample I attached previously:

          C#
          private void simpleButton1_Click(object sender, EventArgs e) { // saving focused cell information GridColumn prevColumn = gridView1.FocusedColumn; int prevRowHandle = gridView1.FocusedRowHandle; gridView1.FocusedRowHandle = Convert.ToInt32(spinEdit1.EditValue); gridView1.FocusedColumn = gridView1.Columns[comboBoxEdit1.EditValue.ToString()]; layoutControlItem2.Text = gridView1.CanShowEditor ? "REGULAR CELL" : "READ_ONLY"; // restoring focused cell information gridView1.FocusedRowHandle = prevRowHandle; gridView1.FocusedColumn = prevColumn; }

          I hope you find this information helpful.

            Seems good
            Thanks and best regards

            DevExpress Support Team 12 years ago

              You are welcome!
              Should you have any questions regarding our products, do not hesitate to contact us.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.