HideEditBox in a DataGrid. Please Help.

  • Thread starter Thread starter Randall Smallwood
  • Start date Start date
R

Randall Smallwood

Hi All,
Has anyone out there used HideEditBox, successfully? I am writing
developing in VB .NET (VS .NET 2002) for the desktop. I have a datagrid
which is ReadOnly. When you click in a cell, the text edit box appears
which looks bad and distracts the user, AND it captures DoubleClick which I
want to handle at the DataGrid level. I have set up a TableStyle and
GridColumnStyles - all ReadOnly. I have created a new class for the
columns, which inherits DataGridTextBoxColumn, and have called HideEditBox
in the constructor. It does absolutely nothing. Here is the class:

Public Class DataGridPassiveColumn
Inherits DataGridTextBoxColumn
Public Sub New()
Me.HideEditBox()
Me.Alignment = HorizontalAlignment.Right
End Sub
End Class

.... I put the Alignment in there just to get some feedback so I know my
class is working (I have to admit I'm new at this). The Alignment works,
the HideEditBox does not.

Can alybody help? I would appreciate it vey much.

Randall Smallwood.
 
HideEditBox is a method that hides the edit box when it's called. It doesn't set an internal field that determines if the Textbox can *ever* be shown, so you'll need to call the method each time someone tries to edit the cell

In your subclass

Private Sub TextBox_Enter(ByVal sender As Object, ByVal e As EventArgs
MyBase.HideEditBox(
End Sub
 
Hi Randall,

If you want a fully R/O column, inherit from the DataGridTextBoxColumn,
override the Edit method and provide a dummy implementation which does just
nothing.
Obviously, do not call the base class implementation.
 
Back
Top