We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

C# class make it work for VB.NET

Thread ID:





630 Jul 18,2002 06:07 AM Jul 18,2002 04:25 PM Windows Forms 2
Tags: FAQ
Asked On July 18, 2002 06:07 AM

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

Administrator [Syncfusion]
Replied On July 18, 2002 03:44 PM

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

Clay Burch [Syncfusion]
Replied On July 18, 2002 04:25 PM

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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.