Results 1 to 4 of 4

Thread: How to use datagridview readonly cell

  1. #1
    Join Date
    Dec 2008
    Posts
    51

    How to use datagridview readonly cell

    I need to make individual cells in a datagridview read-only. But at the initial level i want to make ReadOnly to 3 cells of Text Column only. user can add new row in it, but will not be able to edit rows. Can anyone show me some code of how I could bypass read only cells in DatagridView when pressing TAB key? Is this possible?

  2. #2
    Join Date
    Feb 2006
    Posts
    167

    Re: How to use datagridview readonly cell

    I don't want to set whole column as ReadOnly. The specified value when setting this property would cause the control to enter edit mode, but initialization of the editing cell value failed and either there is no handler for the DataError event. But only those cells of that column, which appears in dataset attached to it.

  3. #3
    Join Date
    Mar 2008
    Posts
    433

    Re: How to use datagridview readonly cell

    Overriding the SelectionChanged event is the right approach. The property CurrentCell can be used to set the current cell. You want something like this, A cell is read-only if the value of the ReadOnly property is true for the cell, the cell's row, the cell's column, or the DataGridView. If e.ColumnIndex = 0 AndAlso e.RowIndex < dgvOpCodes.RowCount - 1 Then e.Cancel = True I would expect I would not be able to type into the cell. If read-only was false, as it is in my control, I would expect to be able to get a cursor.

  4. #4
    Join Date
    Jan 2009
    Posts
    150

    Re: How to use datagridview readonly cell

    Based on my understanding, Inherit DataGridView and override ProcessDialogKey (for key pressed while editing)you have a DataGridView control bound to a data source and have set the ReadOnly property of a bound column in the DataGridView control to False. and ProcessDataGridViewKey (for key pressed while not editing). When Tab was pressed, set CurrentCell to the next non-readonly cell.

Similar Threads

  1. Differentiate between const and static readonly
    By KALLIYAN in forum Software Development
    Replies: 3
    Last Post: 17-11-2009, 12:52 AM
  2. How to call Readonly textbox in Javascript Function
    By Aldous in forum Windows Software
    Replies: 3
    Last Post: 12-08-2009, 11:39 AM
  3. How to resize cell in DataGridView
    By Ebadaah in forum Software Development
    Replies: 3
    Last Post: 10-06-2009, 06:54 PM
  4. Disable cell validation on form DataGridView
    By Chandrakant81 in forum Software Development
    Replies: 3
    Last Post: 06-02-2009, 05:52 PM
  5. Move Rows of Datagridview In VB.Net
    By Ariadne in forum Software Development
    Replies: 2
    Last Post: 22-01-2009, 10:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,084,962.01203 seconds with 16 queries