C# 到 VB.net 项目转换

标签 c# .net vb.net c#-to-vb.net handlers

我正在尝试将 C# 项目转换为 vb.net 项目,但遇到了一些困难。

下面是一个按钮的点击事件:

private void button2_Click(object
sender, EventArgs e)
        {
            Appointment m_App = new Appointment();
            m_App.StartDate = dayView1.SelectionStart;
            m_App.EndDate = dayView1.SelectionEnd;
            m_App.BorderColor = Color.Red;

            m_Appointments.Add(m_App);

            dayView1.Invalidate();
        }

然后调用以下内容:

protected override void
    OnPaint(PaintEventArgs e)
{
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            // resolve appointments on visible date range.
            ResolveAppointmentsEventArgs args = new
        ResolveAppointmentsEventArgs(this.StartDate,
        this.StartDate.AddDays(daysToShow));
            ResolveAppointments(args);

            using (SolidBrush backBrush = new
          SolidBrush(renderer.BackColor))
                  e.Graphics.FillRectangle(backBrush,
          this.ClientRectangle);

            // Visible Rectangle            Rectangle
        rectangle = new Rectangle(0, 0,
              this.Width - VScrollBarWith,
              this.Height);

            DrawDays(ref e, rectangle);

            DrawHourLabels(ref e, rectangle);

            DrawDayHeaders(ref e, rectangle);
}

我已将每个部分转换为 VB.net 代码:

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles Button1.Click
         Dim m_App As New Appointment()
         m_App.StartDate = DayView1.SelectionStart
         m_App.EndDate = DayView1.SelectionEnd
         m_App.BorderColor = Color.Red

         m_Appointments.Add(m_App)

         DayView1.Invalidate()

 End Sub

但它不会自动调用:

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias

            ' resolve appointments on visible date range.'
            Dim args As New ResolveAppointmentsEventArgs(Me.StartDate, >Me.StartDate.AddDays(m_daysToShow))
            ResolveAppointments(args)

            Using backBrush As New SolidBrush(m_renderer.BackColor)
                e.Graphics.FillRectangle(backBrush, Me.ClientRectangle)
            End Using

            ' Visible Rectangle '
            Dim rectangle As New Rectangle(0, 0, Me.Width - VScrollBarWith, Me.Height)

            DrawDays(e, rectangle)

            DrawHourLabels(e, rectangle)

            DrawDayHeaders(e, rectangle)
 End Sub

最佳答案

有一个免费的在线转换实用程序 developerfusion

关于C# 到 VB.net 项目转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3577768/

相关文章:

c# - 如何为 HTML Select 服务器控件创建扩展属性?

c# - Entity Framework 多对象上下文

c# - 调用 `Environment.GetEnvironmentVariable`影响后续调用

asp.net - VB.net 1.1 - 有 Continue For 吗?

.net - 如何确定分布式事务超时的原因

VB.NET 单一数据类型计算问题

c# - 样式,模板和ResourceDictionaries

c# - 如何告诉 lambda 函数捕获副本而不是 C# 中的引用?

c# - Azure 中的 Restful Web 服务 : Web Role or Worker Role?

c# - 逐行读取文本文件的最快方法是什么?