C# class make it work for VB.NET

In your Data Grid sample code you have a C# class that does exactly what I need. How do I make it work in VB.NET. PLease help. Here is the class: public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn { protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight) { // the idea is to conditionally set the foreBrush and/or backbrush // depending upon some crireria on the cell value // Here, we color anything that begins with a letter higher than 'F' try{ object o = this.GetColumnValueAtRow(source, rowNum); if( o!= null) { char c = ((string)o)[0]; if( c > 'F') { // could be as simple as // backBrush = new SolidBrush(Color.Pink); // or something fancier... backBrush = new LinearGradientBrush(bounds, Color.FromArgb(255, 200, 200), Color.FromArgb(128, 20, 20), LinearGradientMode.BackwardDiagonal); foreBrush = new SolidBrush(Color.White); } } } catch(Exception ex){ /* empty catch */ } finally{ // make sure the base class gets called to do the drawing with // the possibly changed brushes base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); } } } I can see the abvious: Public Class Somename Inherits Class DataGridTextBoxCOlumn Protected Overloads Overrides Sub Paint(ByVal g as.........,ByVal alighnToRight as Boolean) But I don't understand how to translate object o=this.GetColumnValueRow(Source, Row).. and the rest ...backBrush=new LinearGrid.... MyBase.Paint(g,bounds,source,rowNum,backBrush,foreBrush,alighnToRight) End Sub End Class

2 Replies

AD Administrator Syncfusion Team July 18, 2002 07:44 PM UTC

If this is just a C# to VB conversion problem, here is a site that can convert random C# code into their VB equivalent: http://www.kamalpatel.net/ConvertCSharp2VB.aspx -Praveen Ramesh


CB Clay Burch Syncfusion Team July 18, 2002 08:25 PM UTC

Attached is an VB project that does the same as the C# project from the FAQ. The FAQ has been updated to contain the VB code also.

Loader.
Up arrow icon