小编Thi*_*ier的帖子

如何确定事件发件人的对象类型?

继承人我的潜意识:

Dim onThisTable as String ="Name"

Private Sub skill_mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.MouseHover, button2.MouseHover, panel1.MouseHover, panel2.MouseHover, pbox1.MouseHover
  descriptionLabel.Text = dbClass.getDescription(sender.Text, onThisTable)
End Sub
Run Code Online (Sandbox Code Playgroud)

现在我希望根据用户传递的内容(面板或pbox或按钮)给onThisTable一个不同的值,但我无法找到比较它是什么类型的正确方法...

Private Sub skill_mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.MouseHover, button2.MouseHover, panel1.MouseHover, panel2.MouseHover, pbox1.MouseHover
  if sender is ( a button )
     onThisTable = "Admin"
  else if sender is ( a panel )
     onThisTable = "dbObject"
  else 
     onThisTable ="Name"
  end if

   descriptionLabel.Text = dbClass.getDescription(sender.Text, onThisTable)
End Sub
Run Code Online (Sandbox Code Playgroud)

vb.net

10
推荐指数
1
解决办法
1万
查看次数

C#string.format添加" - "值?

我有一个string.format问题......

我试图将我的发票ID作为参数传递给我的程序......第6个参数总是以" - "结束,无论我做什么(我们必须使用¿因为旧程序)...

     public static void OpenIdInvoice(string wdlName, string IdInvoice, Form sender){
        MessageBox.Show(string.Format("¿{0}",IdInvoice));
        proc.Arguments = string.Format("{0}¿{1}¿{2}¿{3}¿{4}¿­{5}",
            session.SessionId.ToString(),
            Session.GetCurrentDatabaseName(),
            session.Librairie,
            wdlName,
            "",
            IdInvoice
        );
        System.Windows.Forms.MessageBox.Show(proc.Arguments);
Run Code Online (Sandbox Code Playgroud)

最后," - "总是添加到我的格式化结果中,但仅在我的IdInvoice之前...(因此Id 10在我的参数中最终为-10)

现在有趣的部分...我硬编码一些字符串和......

如果我传递-1而不是Id,我有--1作为结果如果我写"香蕉"...我得到"-banana"...

我知道我可以建立字符串,否则......但我很好奇它为什么会发生.

这是截图  减去香蕉? ...

编辑:

这就是我的代码的复制/粘贴

var proc = new System.Diagnostics.ProcessStartInfo("Achat.exe");
        System.Windows.Forms.MessageBox.Show(string.Format("¿{0}",args));
        proc.Arguments = string.Format(@"{0}¿{1}¿{2}¿{3}¿{4}¿­{5}¿{6}",
            "12346", //session.SessionId.ToString(),
            "fake DB",//Session.GetCurrentDatabaseName().ToString(),
            "false", //session.Librairie.ToString(),
            "myScreenName", //wdl.ToString(),
            "123456",
            "Banana",
            "123456"
            //args.ToString(), 

        );
        System.Windows.Forms.MessageBox.Show(proc.Arguments);
        System.Windows.Forms.MessageBox.Show(args);
Run Code Online (Sandbox Code Playgroud)

那就是我的文本可视化结果的复制/粘贴:

12346¿fakeDB¿false¿myScreenName¿123456¿Banana¿123456

c# string.format .net-4.0

6
推荐指数
1
解决办法
487
查看次数

标签 统计

.net-4.0 ×1

c# ×1

string.format ×1

vb.net ×1