![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | translation needed: C to VB Hi, I found the following code in a FAQ about the datagridview. But I am having a hard time translating it to VB, so I would like to ask via here for someone more experienced to translate this code to VB. When I can read it in VB I want to replace everything about the image into a button. Thanks in advance! Eric. public class TextAndImageColumn ataGridViewTextBoxColumn{ private Image imageValue; private Size imageSize; public TextAndImageColumn() { this.CellTemplate = new TextAndImageCell(); } public override object Clone() { TextAndImageColumn c = base.Clone() as TextAndImageColumn; c.imageValue = this.imageValue; c.imageSize = this.imageSize; return c; } public Image Image { get { return this.imageValue; } set { if (this.Image != value) { this.imageValue = value; this.imageSize = value.Size; if (this.InheritedStyle != null) { Padding inheritedPadding = this.InheritedStyle.Padding; this.DefaultCellStyle.Padding = new Padding(imageSize.Width, inheritedPadding.Top, inheritedPadding.Right, inheritedPadding.Bottom); } } } } private TextAndImageCell TextAndImageCellTemplate { get { return this.CellTemplate as TextAndImageCell; } } internal Size ImageSize { get { return imageSize; } } } public class TextAndImageCell : DataGridViewTextBoxCell { private Image imageValue; private Size imageSize; public override object Clone() { TextAndImageCell c = base.Clone() as TextAndImageCell; c.imageValue= this.imageValue; c.imageSize = this.imageSize; return c; } public Image Image { get { if (this.OwningColumn == null || this.OwningTextAndImageColumn == null) { return imageValue; } else if (this.imageValue != null) { return this.imageValue; } else { return this.OwningTextAndImageColumn.Image; } } set { if (this.imageValue != value) { this.imageValue = value; this.imageSize = value.Size; Padding inheritedPadding = this.InheritedStyle.Padding; this.Style.Padding = new Padding(imageSize.Width, inheritedPadding.Top, inheritedPadding.Right, inheritedPadding.Bottom); } } } protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { // Paint the base content base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); if (this.Image != null) { // Draw the image clipped to the cell. System.Drawing.Drawing2D.GraphicsContainer container = graphics.BeginContainer(); graphics.SetClip(cellBounds); graphics.DrawImageUnscaled(this.Image, cellBounds.Location); graphics.EndContainer(container); } } private TextAndImageColumn OwningTextAndImageColumn { get { return this.OwningColumn as TextAndImageColumn; } } } |
My System Specs![]() |
| | #2 (permalink) |
| | Re: translation needed: C to VB "EricW" <iemand@xxxxxx> wrote in message news:48a5415b$0$6000$9a622dc7@xxxxxx Quote: > Hi, > > I found the following code in a FAQ about the datagridview. > But I am having a hard time translating it to VB, so I would like to ask > via here for someone more experienced to translate this code to VB. > When I can read it in VB I want to replace everything about the image into > a button. > > Thanks in advance! > Eric. > |
My System Specs![]() |
| | #3 (permalink) |
| | RE: translation needed: C to VB (Instant VB) Public Class TextAndImageColumn Inherits DataGridViewTextBoxColumn Private imageValue As Image Private imageSize_Renamed As Size Public Sub New() Me.CellTemplate = New TextAndImageCell() End Sub Public Overrides Function Clone() As Object Dim c As TextAndImageColumn = TryCast(MyBase.Clone(), TextAndImageColumn) c.imageValue = Me.imageValue c.imageSize = Me.imageSize_Renamed Return c End Function Public Property Image() As Image Get Return Me.imageValue End Get Set(ByVal value As Image) If Me.Image IsNot value Then Me.imageValue = value Me.imageSize_Renamed = value.Size If Me.InheritedStyle IsNot Nothing Then Dim inheritedPadding As Padding = Me.InheritedStyle.Padding Me.DefaultCellStyle.Padding = New Padding(imageSize_Renamed.Width, inheritedPadding.Top, inheritedPadding.Right, inheritedPadding.Bottom) End If End If End Set End Property Private ReadOnly Property TextAndImageCellTemplate() As TextAndImageCell Get Return TryCast(Me.CellTemplate, TextAndImageCell) End Get End Property Friend ReadOnly Property ImageSize() As Size Get Return imageSize_Renamed End Get End Property End Class Public Class TextAndImageCell Inherits DataGridViewTextBoxCell Private imageValue As Image Private imageSize As Size Public Overrides Function Clone() As Object Dim c As TextAndImageCell = TryCast(MyBase.Clone(), TextAndImageCell) c.imageValue= Me.imageValue c.imageSize = Me.imageSize Return c End Function Public Property Image() As Image Get If Me.OwningColumn Is Nothing OrElse Me.OwningTextAndImageColumn Is Nothing Then Return imageValue ElseIf Me.imageValue IsNot Nothing Then Return Me.imageValue Else Return Me.OwningTextAndImageColumn.Image End If End Get Set(ByVal value As Image) If Me.imageValue IsNot value Then Me.imageValue = value Me.imageSize = value.Size Dim inheritedPadding As Padding = Me.InheritedStyle.Padding Me.Style.Padding = New Padding(imageSize.Width, inheritedPadding.Top, inheritedPadding.Right, inheritedPadding.Bottom) End If End Set End Property Protected Overrides Sub Paint(ByVal graphics As Graphics, ByVal clipBounds As Rectangle, ByVal cellBounds As Rectangle, ByVal rowIndex As Integer, ByVal cellState As DataGridViewElementStates, ByVal value As Object, ByVal formattedValue As Object, ByVal errorText As String, ByVal cellStyle As DataGridViewCellStyle, ByVal advancedBorderStyle As DataGridViewAdvancedBorderStyle, ByVal paintParts As DataGridViewPaintParts) ' Paint the base content MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts) If Me.Image IsNot Nothing Then ' Draw the image clipped to the cell. Dim container As System.Drawing.Drawing2D.GraphicsContainer = graphics.BeginContainer() graphics.SetClip(cellBounds) graphics.DrawImageUnscaled(Me.Image, cellBounds.Location) graphics.EndContainer(container) End If End Sub Private ReadOnly Property OwningTextAndImageColumn() As TextAndImageColumn Get Return TryCast(Me.OwningColumn, TextAndImageColumn) End Get End Property End Class -- http://www.tangiblesoftwaresolutions.com C++ to C# C++ to VB C++ to Java VB & C# to Java Java to VB & C# Instant C#: VB to C# Instant VB: C# to VB Instant C++: VB, C#, or Java to C++/CLI "EricW" wrote: Quote: > Hi, > > I found the following code in a FAQ about the datagridview. > But I am having a hard time translating it to VB, so I would like to ask via > here for someone more experienced to translate this code to VB. > When I can read it in VB I want to replace everything about the image into a > button. > > Thanks in advance! > Eric. > > > public class TextAndImageColumn ataGridViewTextBoxColumn> { > private Image imageValue; > private Size imageSize; > > public TextAndImageColumn() > { > this.CellTemplate = new TextAndImageCell(); > } > > public override object Clone() > { > TextAndImageColumn c = base.Clone() as TextAndImageColumn; > c.imageValue = this.imageValue; > c.imageSize = this.imageSize; > return c; > } > > public Image Image > { > get { return this.imageValue; } > set > { > if (this.Image != value) { > this.imageValue = value; > this.imageSize = value.Size; > > if (this.InheritedStyle != null) { > Padding inheritedPadding = > this.InheritedStyle.Padding; > this.DefaultCellStyle.Padding = new > Padding(imageSize.Width, > inheritedPadding.Top, inheritedPadding.Right, > inheritedPadding.Bottom); > } > } > } > } > private TextAndImageCell TextAndImageCellTemplate > { > get { return this.CellTemplate as TextAndImageCell; } > } > internal Size ImageSize > { > get { return imageSize; } > } > } > > public class TextAndImageCell : DataGridViewTextBoxCell > { > private Image imageValue; > private Size imageSize; > > public override object Clone() > { > TextAndImageCell c = base.Clone() as TextAndImageCell; > c.imageValue= this.imageValue; > c.imageSize = this.imageSize; > return c; > } > > public Image Image > { > get { > if (this.OwningColumn == null || > this.OwningTextAndImageColumn == null) { > > return imageValue; > } > else if (this.imageValue != null) { > return this.imageValue; > } > else { > return this.OwningTextAndImageColumn.Image; > } > } > set { > if (this.imageValue != value) { > this.imageValue = value; > this.imageSize = value.Size; > > Padding inheritedPadding = this.InheritedStyle.Padding; > this.Style.Padding = new Padding(imageSize.Width, > inheritedPadding.Top, inheritedPadding.Right, > inheritedPadding.Bottom); > } > } > } > protected override void Paint(Graphics graphics, Rectangle > clipBounds, > Rectangle cellBounds, int rowIndex, DataGridViewElementStates > cellState, > object value, object formattedValue, string errorText, > DataGridViewCellStyle cellStyle, > DataGridViewAdvancedBorderStyle advancedBorderStyle, > DataGridViewPaintParts paintParts) > { > // Paint the base content > base.Paint(graphics, clipBounds, cellBounds, rowIndex, > cellState, > value, formattedValue, errorText, cellStyle, > advancedBorderStyle, paintParts); > > if (this.Image != null) { > // Draw the image clipped to the cell. > System.Drawing.Drawing2D.GraphicsContainer container = > graphics.BeginContainer(); > > graphics.SetClip(cellBounds); > graphics.DrawImageUnscaled(this.Image, cellBounds.Location); > > graphics.EndContainer(container); > } > } > > private TextAndImageColumn OwningTextAndImageColumn > { > get { return this.OwningColumn as TextAndImageColumn; } > } > } > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| CBS Log translation? | Network & Sharing | |||
| Language Translation | Vista General | |||
| chat translation | Live Messenger | |||
| web page translation... | Vista General | |||
| Need Translation into English. | Vista General | |||