如何在DatagridView中呈现HashTable ......? [英] How to Present HashTable in DatagridView...?

查看:127
本文介绍了如何在DatagridView中呈现HashTable ......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我的程序中有一个哈希表,只是我想在我的c#表单应用程序中将这个hashTable的所有键值对显示到Datagrid视图中...

kINDLY回答my问题我尝试了该代码,但没有任何反应...



My question is that i have an hashtable in my program , simply i want to display all key,value pair of this hashTable into Datagrid view in my c# form application...
kINDLY answer my question i tried that code but nothing happens...

 dataGridView1.DataSource = hashtable.Cast<DictionaryEntry>().Select(x => new { Col1 = x.Key.ToString(), Col2 = x.Value.ToString() }).ToList();}</pre>

I have posted that same question to forums but still no one has helped me...

I am surprised that why these programmers are not able of answering this question...

推荐答案

我只是无法理解它是如何成为一个问题。可以有不同的方式来实现这一目标。在最简单的情况下,您创建两个字符串列(不计算行标题),一个表示键,另一个表示值。在所有键值对的循环中,填写两列。这将需要几行代码。由于我不知道您是否要编辑数据,因此您需要至少使密钥列为只读,因为编辑密钥将是无效操作。根据值的类型,您可以编辑它们。



-SA
I just cannot understand how it can be a problem. There can be different way to achieve that. In simplest case, you create two string columns (not counting row headers), one representing keys, another one — values. In the loop by all key-value pairs, fill in both columns. It will take few lines of code. As I don't know if you want to edit data, you need to make at least the key column read-only, because editing a key would be invalid operation. Depending on the type of the values, you might be able to edit them.

—SA


这篇关于如何在DatagridView中呈现HashTable ......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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