请问如何在vb.net中翻译此代码c# [英] How do translate this code c# in vb.net, please

查看:122
本文介绍了请问如何在vb.net中翻译此代码c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请大家好,我在c#项目中有这个代码,我想转换成我在代码翻译器中试过的vb.net,但是没有工作。谢谢



a对某人的巨大挑战



当我们需要在表单中处理多个视图时通常使用TabControl,但是当我们需要并且功能非常复杂或者只是想在不同的界面中将这些功能分开并将它们集成到一个表单中时,我们使用MDI表单,这些表单我们可以使用父表(容器)表单和孩子(内容),个人我没有反对这些,但我似乎有点乏味的工作和一些严格的定制。



这就是为什么有一次,当我需要做一个这样的项目,我决定整合另一个方法来耦合表单一个父母没有孩子,这是一个MDI容器,或使用TabControls。看到Visual Studio ToolBox面板中的容器部分看到了一个简单但功能强大的控件,这样最终将是我问题的最佳解决方案,这里就像我一样。



澄清了这个背景,交给键盘,我们要做的第一件事就是创建一个Windows Forms项目类型,这将添加三个表单(Father,Child1,child2):



第1部分:



private void btMostrarHijo1_Click(object sender,EventArgs e)

{

if(this.panelContenedor.Controls.Count& gt; 0)

this.panelContenedor.Controls.RemoveAt(0);

Hijo1 form = Application.OpenForms.OfType< hijo1>()。FirstOrDefault();

Hijo1 hijo1 = form ?? new Hijo1();

hijo1.FormBorderStyle = FormBorderStyle.None;

hijo1.Dock = DockStyle.Fill;

this.panelContenedor.Controls .Add(hijo1);

this.panelContenedor.Tag = hijo1;

hijo1.Show();

}







第2部分



private void AddFormInPanel(Form fh)

{

if(this.panelContenedor.Controls.Count& gt; 0)

this .panelContenedor.Controls.RemoveAt(0);

fh.TopLevel = false;

fh.FormBorderStyle = FormBorderStyle.None;

fh.Dock = DockStyle.Fill;

this.panelContenedor.Controls.Add(fh);

this.panelContenedor.Tag = fh;

fh.Show();

}





第3部分





private void btMostrarHijo2_Click(object sender,EventArgs e)

{

var form = Application.OpenForms.OfType< hijo2>( ).FirstOrDefault();

Hijo2 hijo = form ??新的Hijo2();

AddFormInPanel(hijo);

}

Please Hi all, I have this code in c# project and i would like to convert into vb.net i tried in code translator , but did not Works. thank you

a big challenge for someone

When we need to work multiple "views" in our forms usually resorted to TabControl, but when we need and functionality is very complex or simply want to separate these functions in different interfaces and integrate them into a single form, we use the MDI forms, these forms we can work with parents (container) forms and children (content), personally I have nothing against these, but I seem somewhat tedious work and some strict customization.

That is why on one occasion, when I needed to make a project like that, I decided to integrate another method for coupling forms one parent without children that this was an MDI CONTAINER, or work with TabControls. Seeing the container section in the Visual Studio ToolBox panel saw, a simple but powerful control so that the final would be the best solution to my problem, here I am as I did.

Having clarified this background, hands to the keyboard, the first thing we do is create a Windows Forms project type, this will going to add three Forms (Father, Child1, child2):

PART 1:

private void btMostrarHijo1_Click(object sender, EventArgs e)
{
if (this.panelContenedor.Controls.Count &gt; 0)
this.panelContenedor.Controls.RemoveAt(0);
Hijo1 form = Application.OpenForms.OfType<hijo1>().FirstOrDefault();
Hijo1 hijo1 = form ?? new Hijo1();
hijo1.FormBorderStyle = FormBorderStyle.None;
hijo1.Dock = DockStyle.Fill;
this.panelContenedor.Controls.Add(hijo1);
this.panelContenedor.Tag = hijo1;
hijo1.Show();
}



PART 2

private void AddFormInPanel(Form fh)
{
if (this.panelContenedor.Controls.Count &gt; 0)
this.panelContenedor.Controls.RemoveAt(0);
fh.TopLevel = false;
fh.FormBorderStyle = FormBorderStyle.None;
fh.Dock = DockStyle.Fill;
this.panelContenedor.Controls.Add(fh);
this.panelContenedor.Tag = fh;
fh.Show();
}


PART 3


private void btMostrarHijo2_Click(object sender, EventArgs e)
{
var form = Application.OpenForms.OfType<hijo2>().FirstOrDefault();
Hijo2 hijo = form ?? new Hijo2();
AddFormInPanel(hijo);
}

推荐答案

你是怎么做到的?简单。研究源代码并理解它的作用,然后在VB.NET中编写等效的代码。



哦,这不是C ++代码。它是C#。
How do you do it? Simple. Study the source code and understand what it does, then write the equivalent code in VB.NET.

Oh, and that's not C++ code. It's C#.


几乎不可能帮助那些甚至不知道有问题的语言的人(当然是C#)。然而......



但你可以自动在C#和VB.NET之间轻松翻译;特别是使用开源ILSpy,您可以翻译整个组件,质量非常好。请参阅我以前的回答:代码解释,C#到VB .NET [ ^ ]。



-SA
It's nearly impossible to help someone who does not even know what is the language in question (it's C#, of course). Nevertheless…

But you can easily translate between C# and VB.NET automatically; in particular, with open-source ILSpy, you can translate the whole assembly, with amazingly good quality. Please see my past answer: Code Interpretation, C# to VB.NET[^].

—SA


这篇关于请问如何在vb.net中翻译此代码c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆