从Excel填充ComboBox和Textfields(Populate ComboBox and Textfields from Excel)
我有一个excel电子表格,其中包含客户信息。 我想填充一个组合框(comboBox1),其中包含来自A列的唯一值。然后,我想要第二个组合框(comboBox2)列出B列中存在comboBox1 = A列的值。最后,我想要使用列C,D,E等填充文本字段....
我已经嘲笑了我想要的结果的快速屏幕:
这将来自以下电子表格:
电子表格中的数据会不时变化,这就是我无法对信息进行硬编码的原因。
我不知道从哪里开始。 我是否将数据加载到2D数组中,或者有更好的方法吗?
I have an excel spreadsheet, that contains client information. I would like to populate a combo box (comboBox1) with unique values from Column A. I would then like a second combo box (comboBox2) to list the values from Column B that exist where comboBox1=Column A. Finally, I would like to populate text fields with column's C, D, E and so on....
I have mocked up a quick screen of my desired result:
This would be derived from the following spreadsheet:
The data in the spreadsheet changes from time to time, which is why I can not hard code the information.
I am not sure where to even start with this. Do I load the data into 2D arrays or is there a better way of doing it?
原文:https://stackoverflow.com/questions/13276130
最满意答案
我使用这种方法来解决问题:
public void ReadByIdTestHelper<ObjectType>() { string schema = "dbo"; long id = 1; Sol.Movie movie = new Movie(); ObjectType actual; actual = Sol.Data.Object.ReadById<ObjectType>(schema, id); Assert.AreEqual((actual is ObjectType), true); } [TestMethod()] public void ReadByIdTest() { ReadByIdTestHelper<Sol.Movie>(); }
不知道这是否是最好的方法。
I used this method to fix the problem:
public void ReadByIdTestHelper<ObjectType>() { string schema = "dbo"; long id = 1; Sol.Movie movie = new Movie(); ObjectType actual; actual = Sol.Data.Object.ReadById<ObjectType>(schema, id); Assert.AreEqual((actual is ObjectType), true); } [TestMethod()] public void ReadByIdTest() { ReadByIdTestHelper<Sol.Movie>(); }
Don't know whether this is the best way to do this though.
相关问答
更多-
简短的答案是typeof(Q)。 长答案(试图解释为什么你不能枚举这些类型,你必须专门编写它们)是这样的: 每个泛型方法(它比声明类更通用)具有相应的,不同的MethodInfo实例,用于其所有(曾经)触及的详细信息以及用于“模板”/打开方法的另一个MethodInfo。 你可以用它来获得你想要的东西: class ConcreteFoo { public void GenericMethod
(Q q) { var method = MethodInfo.GetCurrentM ...
-
我使用这种方法来解决问题: public void ReadByIdTestHelper
() { string schema = "dbo"; long id = 1; Sol.Movie movie = new Movie(); ObjectType actual; actual = Sol.Data.Object.ReadById (schema, id); Assert.AreEqual((actual is ... -
这看起来不太合适: if(root == null){ root = node; } 为什么? root是您的方法中定义的变量。 它与您实例中的字段没有相同的生命周期 。 private boolean put(Node
node, Node root) 在这里实际使用bstRoot作为空树会更可靠。 if(bstRoot == null){ bstRoot = node; } This doesn't look quite right: if(root == nu ... -
这里的解决方案是信任成员对象的equals方法只匹配正确的类型。 你确实需要在这里使用instanceof,你不应该使用rawtypes,但它应该看起来像 @Override public boolean equals(Object o) { if (o instanceof Combination) { Combination> c = (Combination>) o; return objects.equals(c.objects); } return false; ...
-
您不知道方法体中的类型。 如果你知道这种类型,那么你首先就不会使用泛型。 您可能不想在这里使用泛型。 如果您需要根据类型做出决定,那么您的方法不是通用的 。 You don't know the type in the body of the method. If you knew the type then you would not have used generics in the first place. You might not want to use generics here. If you ...
-
我不清楚你想要什么 - 你想在一个不同于通用类ItemDelegate
参数上使用filter泛型吗? 然后我猜你应该使用不同的参数名称作为最低要求: public class ItemDelegate { public U filter() { return null; } } 或者如果您需要相同的参数,请不要重新声明: public class ItemDelegate { public T filter() { retu ... -
你想在运行时得到一个Class
,或许我们可以提出一个解决方法。 You want to get a Class at runtime to pass to doSomethingElse()? No, that is not possible. If you describe why doSomethingElse needs a Class , pe ... -
首先,让我们看看如何做到这一点: IPrice
test = new BnSPrice(5); test.subtractPrice(new BnSPrice(5)); 好的,所以删除通配符? extends ... ? extends ...作品。 为什么? 您需要了解通用通配符的概念。 extends BnPrice> extends BnPrice>意味着它可以是任何类型的BnPrice的子类。 目前,你还没有,但为了证明我的观点,我们创建一个。 class MyPr ... -
SafeGetValue有4个参数,在调用中你传递3个: new[] {attrName , Type.Missing, Type.Missing}, 您缺少第一个参数XElement 可能你想通过 new[] {_doc.Element(elementName), attrName , Type.Missing, Type.Missing}, SafeGetValue takes 4 parameters and in invocation you pass 3: new[] {attrName , ...
-
在使用之前,您需要声明该方法的type参数。 要创建泛型方法,请在返回类型之前声明type参数: private
void assertIteratorThrowsNoSuchElement(Deque deque, Class cl) { } 此外,我没有看到任何使用第二参数。 你甚至没有使用它。 类型参数T是从您传递的实际类型中自动推断出来的。 如果您已为此目的添加它,则可以将其删除。 只需保留第1个参数。 You need to declare the type paramete ...