首页 \ 问答 \ 来自DatagridView数据源的临时DataTable(Temporary DataTable from DatagridView datasource)

来自DatagridView数据源的临时DataTable(Temporary DataTable from DatagridView datasource)

我有一个数据表,它是从datagridview数据源创建的,并希望对该数据表进行修改,如:

DataTable dt = (DataTable)dataGridView1.DataSource;
dt.Remove("xyz");

这会从dt中删除xyz列,但是也会从datagridview的原始数据源中删除它。 但我想将此dt仅用于临时目的,并且不希望将列从原始列中删除。

为什么它们的行为类似于绑定变量,我该如何处理?


I have a datatable which created from a datagridview datasource and want to make modifications on that datatable like:

DataTable dt = (DataTable)dataGridView1.DataSource;
dt.Remove("xyz");

This removes the xyz column from dt, well, but removes it from the datagridview's original datasource too. But i want to use this dt for only temporary purposes and not want the column to be removed from original.

Why do they behave like binded variables and how can I handle this?


原文:https://stackoverflow.com/questions/37616853
更新时间:2022-09-26 11:09

最满意答案

由于在C ++中实现了迭代器,它是否会发生一些事情

不,这是未定义的行为。 迭代器已变为无效,无法使用。

是因为内存段被宣布为免费使用,但尚未更改?

是的,这就是你观察你所观察到的东西的原因。 但是内存可以被重用于其他东西,或者无法访问 - 你不能依赖任何未定义行为的观察。


Is it something bound to happen due to the implementation of iterators in C++

No, it's undefined behaviour. The iterator has become invalid, and can't be used.

is it because the segment of the memory was declared as free for used, but hasn't been changed yet?

Yes, that's why you observed what you observed. But the memory could be reused for something else, or made inaccessible - you can't rely on any observations of undefined behaviour.

相关问答

更多
  • set包含具有唯一值的不可变对象,但goo需要非const引用。 更改goo以获取const引用,使用除集合之外的其他内容,或者创建对象的副本。 只要对象在集合中,就不能对其进行修改,因此无法将其传递给修改(或可以修改)对象值的函数。 A set contains immutable objects with unique values, but goo requires a non-const reference. Either change goo to take a const reference, ...
  • 由于在C ++中实现了迭代器,它是否会发生一些事情 不,这是未定义的行为。 迭代器已变为无效,无法使用。 是因为内存段被宣布为免费使用,但尚未更改? 是的,这就是你观察你所观察到的东西的原因。 但是内存可以被重用于其他东西,或者无法访问 - 你不能依赖任何未定义行为的观察。 Is it something bound to happen due to the implementation of iterators in C++ No, it's undefined behaviour. The iterat ...
  • 从Python教程 : 修改循环中迭代的序列是不安全的(这只能发生在可变序列类型中,例如列表)。 如果您需要修改正在迭代的列表(例如,复制所选项目),则必须迭代副本。 切片表示法使这特别方便: >>> for x in a[:]: # make a slice copy of the entire list ... if len(x) > 6: a.insert(0, x) ... >>> a ['defenestrate', 'cat', 'window', 'defenestrate'] Fro ...
  • 每次调用it.next() ,都会获得下一个元素并向前移动光标。 相反,存储实例,执行检查并执行单击,如: WebElement e; while(it.hasNext()) e = it.next(); if(e.getText().equals(cat)) { e.click(); } } Each time you call it.next(), you get the next element AND move the cursor ahead. Inste ...
  • 我觉得这相当pythonic。 我只想改为: def parse_data: if isinstance(value, dict): iterator = value.items() elif isinstance(value, list): iterator = enumerate(value) else: return for key, item in iterator: parse_data(value ...
  • 一个主要问题是你(显然,你没有提供完整的代码) delete一个对象两次:一次迭代列表A,一次迭代列表B. 主要有三种解决方案: 使用像std::shared_ptr这样的ref-counting智能指针。 推荐的。 你不想使用智能指针的陈述似乎是出于无知,而不是一些愚蠢的经理的要求。 将节点保留在主列表中: 只有当您知道它所在的唯一列表是主列表时才delete节点。 自己实施引用计数: 最简单的方法是再次使用现有的库解决方案,例如boost::intrusive_ptr ,但您所要做的就是在每个节点中精心 ...
  • 改变这个: std::list::const_iterator goop = bob.begin(); 对此: std::list::const_iterator goop = bob.begin(); 因为你需要指向整数的指针 ,在你的第一个例子中。 Change this: std::list::const_iterator goop = bob.begin(); to this: std::list::const_iterator goop = bob ...
  • auto midiMessage = queuedNotes.begin(); midiMessage的类型为std::multiset::iterator 。 并且它无法转换为您的类型IMidiMsgExt 。 Iterator是一个与指针行为类似的对象,因此您可以使用取消引用运算符( * )来获取它“指向”的对象。 您也不需要将派生对象强制转换为其基础,这是隐式完成的。 您需要做的就是获取迭代器“指向”的地址以获取指向IMidiMsgExt的指针: SendMidiMsg(&*midiMessage) ...
  • 使用std :: ostringstream而不是std :: cout http://www.cplusplus.com/reference/sstream/ostringstream/ #include .... std::ostringstream names; std::string delimiter = ","; std::list::const_iterator it = pNames->begin(); if (it != pNames->cend()) ...
  • 第一个节点的prev指针是NULL,所以是最后一个节点的下一个指针。 一个接一个的结束current指针将为NULL。 operator-> First node's prev pointer is NULL, so is last node's next pointer. One-past-the-end's current pointer would be NULL. operator->

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)