English 中文(简体)
C# 重写问题
原标题:C# Question regarding rewriting from VB
  • 时间:2010-09-28 12:39:48
  •  标签:
  • c#

I m a VB guy learning C#.I. See also hanging the hang of it but I ve got a both questions regarding somecode Im written.

在我这里的头一起,我这样写我的法典就错了:

Irowindex = sF1411BindingSource.Find(sF1411DataSet.SF1411.Columns(groupBox4.Tag.ToString).ToString, textBox1.Text);
        if (Irowindex == -1)

Error 1 System.Data.DataTable. 颜色是一种财产,但使用的方法是C:11180_APPLATION11180_APPLICATIONEdit.cs 186 71 11180_APPLATION

我的另一个问题是,在VB I使用Taks,但在C#中,它似乎与他们一样:

//Set the find label to display the new find column
groupBox4.Text = "Find - " + sender.Tag.ToString + ":";
//Store the sort column name in lblFind s Tag property
groupBox4.Tag = sender.Tag.ToString;

第4项目标没有包含Tag C:11180_APPLATION11180_APPLICATIONEdit.cs 211 36 11180_APPLATION

这里有什么想法?

最佳回答

Try Columns[groupBox4.Tag.ToString ()] for the first wrong.

关于标的,在C#中,投放者是类型目标,它确实有tag物。 首先控制:

((Control)sender).Tag
问题回答

您需要用C# syntax取代索引检索器(在VB .Columns(......)中,使用方括号。

.Columns[...]

就其他错误而言。 如同你的控制一样,这种控制被归类为目标(在VB中受逾期约束)。 你们要么需要改变控制定义,要么使用全部类型(或至少控制)......,要么投到控制处。

http://www.un.org/Depts/DGACM/index_chinese.htm 其方法。

此外,Columns是一种收集和使用索引,在这种情况下,你需要使用。 而不是()

。 怀孕后应有母体。

foo.ToString()

所有方法电话都应当有(> e.gToString()。

所有索引人都应有<代码>[]w.g。 Columns[...]

并且,您可能不得不将案件打上“(TextBox)sender”等字样。 文本

对于您的第二个问题,sender大概是某些活动手递的参数......

protected void HandlerName(object sender, EventArgs e) { ... }

如果情况是这样,而且你想把发交者当作其他类别,那么你就应该这样做:

YourClass mySender = sender as YourClass;
if (mySender != null) {
  // Do your handling here
}

之后@gabriel 修订后的法典如下:

private void radioButton1_CheckedChanged(object sender, EventArgs e){
    RadioButton radioSender = sender as RadioButton;
    if (radioSender != null){
        sF1411BindingSource.Sort = radioSender.Tag.ToString();
        sF1411BindingSource.MoveFirst();
        //Set the find label to display the new find column
        groupBox4.Text = "Find - " + radioSender.Tag.ToString() + ":";
        //Store the sort column name in lblFind s Tag property
        groupBox4.Tag = radioSender.Tag.ToString();
        textBox1.ReadOnly = false;
    }
}

你们需要地方图书馆(索引员)。 IOW [ ]/code> and not ( )





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...