Jump to content
Xtreme .Net Talk

Recommended Posts

  • 4 weeks later...
Posted
did you find out how to do this yet. I have been searching for a solution to this for a while. It is possible to do as I have found a 3rd party component that does it, but I can not use this as I need to have all the code in my application. If you have solved this please let me know.
Hamlet
  • 1 month later...
Posted

First, create a class with this code...

 

Public Class CNGridMultiLineTextBox

Inherits System.Windows.Forms.DataGridTextBoxColumn

 

Protected Overloads Overrides Sub Edit(ByVal source As CurrencyManager, ByVal rowNum As Integer, ByVal bounds As Rectangle, ByVal readOnly1 As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)

DataGridTableStyle.DataGrid.Select(rowNum)

End Sub

 

Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing.Brush, ByVal foreBrush As System.Drawing.Brush, ByVal alignToRight As Boolean)

MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)

 

g.FillRectangle(backBrush, bounds)

Dim vText As String

If IsDBNull(MyBase.GetColumnValueAtRow(source, rowNum)) Then

vText = ""

Else

vText = CType(MyBase.GetColumnValueAtRow(source, rowNum), String)

End If

 

g.DrawString(vText, Me.TextBox.Font, foreBrush, New RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height))

End Sub

 

Protected Overrides Sub ColumnStartedEditing(ByVal editingControl As System.Windows.Forms.Control)

 

End Sub

 

 

End Class

 

 

Then update the rowheight of your grid. It did work for me.

  • 2 weeks later...
Posted

Hi grivero,

I presume you mean updating the PrefferedRowHeight of the grid. If this is the case it canges all the rows of the grid, not just the ones that need to be changed.

Hamlet
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...