首页 \ 问答 \ WPF Datagrid。(WPF Datagrid. Get the values of each cell of the selected row)

WPF Datagrid。(WPF Datagrid. Get the values of each cell of the selected row)

我正在使用WPF工具包DataGrid。

我怎样才能得到所选行的单元格的值?


I'm using the WPF toolkit DataGrid.

How can I get the values of the cells of the selected rows?


原文:https://stackoverflow.com/questions/1570929
更新时间:2021-12-03 20:12

最满意答案

除非您控制输入,否则最佳情况通常无用。 (即最好的情况通常是异常情况)。 除非它易于计算,否则不值得浪费你的时间。

平均情况:一般来说,这是你能想到的。 假设您使用大量输入,这通常是最有用的考虑因素。

最糟糕的情况:对于具有相同平均情况的两种算法,如果你处理任意输入(特别是如果它们是不可信的 - 即你接受来自网络上的人的输入),那么它是一个合适的打破平局。 在设计中也需要考虑一下 - 偶尔会出现这种情况。 一般来说,如果你有两个算法是O(n)平均情况,但一个是O(n lg n)最坏情况,一个是O(n ^ 2) - 它可能会影响你决定使用哪个。 或者它可能会影响您的算法设计。

示例:快速排序v。合并排序。 两者都是O(n lg n)Quicksort的最坏情况是O(n ^ 2),合并排序是(IIRC)仍然是O(n lg n) - 但是一般来说,如果数据适合内存,Quicksort往往会更快。 即使它有一个更昂贵的最坏情况,因为我们知道它有一个更昂贵的最坏情况,我们可以尝试缓解它(三个中位数而不是一个随机分区等)并利用它通常的事实比mergesort快。


Best case is generally useless unless you control the inputs. (i.e. best case is usually an anomalous case). Unless it's easy to compute, it's not worth wasting your time.

Average case: it's what can you expect in general. Assuming you work with a large range of inputs, this is usually the most useful thing to consider.

Worst case: a decent tie breaker for two algorithms with the same average case, if you deal with arbitrary inputs (especially if they're untrusted - i.e. you're accepting inputs from people on the web). Also something to consider in design in general - this will come up occasionally. In general, if you have two algorithms that are O(n) average case, but one is O(n lg n) worst case, and one is O(n^2) - it may influence your decision on which to go with. Or it may influence your algorithm design.

Example: quick sort v. merge sort. Both are O(n lg n) Quicksort's worst case is O(n^2), merge sort is (IIRC) still O(n lg n) - but in general, Quicksort tends to be faster if data fits in memory. Even though it has a costlier worst case, since we KNOW it has a costlier worst case, we can try to mitigate it (median-of-three instead of just a random partition, etc.) and take advantage of the fact that it usually is faster than mergesort.

相关问答

更多
  • 除非您控制输入,否则最佳情况通常无用。 (即最好的情况通常是异常情况)。 除非它易于计算,否则不值得浪费你的时间。 平均情况:一般来说,这是你能想到的。 假设您使用大量输入,这通常是最有用的考虑因素。 最糟糕的情况:对于具有相同平均情况的两种算法,如果你处理任意输入(特别是如果它们是不可信的 - 即你接受来自网络上的人的输入),那么它是一个合适的打破平局。 在设计中也需要考虑一下 - 偶尔会出现这种情况。 一般来说,如果你有两个算法是O(n)平均情况,但一个是O(n lg n)最坏情况,一个是O(n ^ 2 ...
  • 您的树有N个目录和M个文件。 迭代时,每个目录和文件都将被处理一次。 所以时间复杂度将是O(M + N)。 或者您可以决定处理目录和文件的时间大致相同,然后您可以说它的O(N)。 树的结构无关紧要。 如果你有一个非常深的目录和子目录树,或者一个非常浅的树,其中所有目录都是根目录的子目录 - 每个文件和每个目录都会被访问一次。 当你看到搜索树的算法,比如平衡二叉树,具有小于线性的复杂性 - 因为它描述了那个不访问每个节点的树上的搜索。 Your tree has N directories and M fil ...
  • 对于实时系统,您需要最差的复杂性; 涵盖您的飞机安全和保证国家预测。 有很多应用程序可能需要分期付款和平均案例分析(假设您知道“平均案例”分布),甚至是平滑分析以及最差情况。 有些系统中,“最佳”算法的选择取决于您是在讨论“最差”还是“平均”,有时他们会并行运行多种算法,并且哪种结束会更快地中止其他结果和输出。 For real-time systems you need worst-case complexity; that covers your plane safety and guaranteed ...
  • 你实际上做了一个简单的随机抽样集。 在从N个元素中选择的n个样本之后选择任何给定元素的机会由下式给出: P(n) = 1 - (1 - 1/N)^n 关于简单随机样本的维基百科文章。 Your in effect doing a simple random sample of the set. The chance any given element is selected after n samples selected from N elements is given by: P(n) = 1 - ( ...
  • 我不确定“非详尽无遗”有一个很好的定义。 无论如何我会试着回答。 找到寻找最大集团的问题 。 我们可以通过一个布尔向量来参数化搜索空间,该布尔向量指示每个顶点是否属于该集团,产生2 n种可能性,没有先验可排除,但每个n顶点图最多有3 n /3≤1.5n 个最大集团,甚至一个相当简单的算法,如Bron-Kerbosch实现了这个多边形因子。 (维基百科的文章描述了指数基数的后续改进。) 另一个例子是汉密尔顿路径 。 有n! 完整图中的不同解决方案,没有先验可排除的,但是存在一个动态程序来找到具有运行时间2 n ...
  • 这是我发现的一个很好的链接... https://prosuncsedu.wordpress.com/2011/04/10/best-case-and-worst-case-situation-of-sorting-algorithms/ Here is a good link I found... https://prosuncsedu.wordpress.com/2011/04/10/best-case-and-worst-case-situation-of-sorting-algorithms/
  • 口语:通常,一般情况。 这就是人们说Quicksort是O(N log N)时间并且哈希表查找是O(K)时间(K =密钥大小)的原因。 它们分别是最坏情况O(N ^ 2)和O(K * N)。 我建议明确。 学术上:通常,最坏的情况。 然而,在学术界,人们通常有兴趣证明给定问题的复杂性类,而不是检查算法的复杂性。 对于院士来说,算法可能只是一个方便的证据,可以证明复杂性的上限而不是实际的研究对象。 另一个问题是“平均情况”完全取决于输入分布。 大多数人都假设均匀分布,除非他们使用短语“真实世界”,此时任何人都 ...
  • Algorithm What(A,n) A <-- new 2D array of n*n integers s <-- 0 for I <-- 2 to n-2 do for j <-- I-2 to n-1 do ---> this executes (n-1)-(I-2)+1 times=n-I+2 times s <--s + A[I][j] end for end for 分析 所以T(n)=和I(n-I + 2)= 0 ...
  • 你是对的,“平均情况复杂性”需要仔细定义算法和可能的输入集合。 搜索线性整数列表所需的比较次数提供了一个示例。 如果输入搜索关键字可以是任意整数,则平均结果是将搜索整个列表(需要n + 1次比较才能找到标记)因为数组中存在无限多个整数且只有有限多个元素。 只有有限数量的输入需要少于n + 1个比较,但无限多个将导致n + 1。 另一方面,如果分析是从数组中的元素(统一)中随机选择搜索关键字(并且这些元素不包含重复)时的平均比较次数,则可能结果的平均值将是比较次数当搜索项目在列表中的第一个加上在列表中第二个时 ...
  • 简短的回答是, 看起来你没有正确选择枢轴,以便(甚至接近)最好的情况。 事实上,鉴于你似乎在选择枢轴,我很惊讶排序有序数据甚至不比你所展示的更差。 要使有序数据成为最佳情况,您需要选择枢轴作为当前分区部分中间的元素。 在这种情况下,您不必移动任何元素来执行分区。 除此之外:IMO,您的代码不必要地难以阅读。 例如, p和r作为参数名称非常接近无意义。 更好的名称将有助于破译您的代码。 但是,除非你有非常具体的理由不这样做,否则我也会考虑更换你的: int aux = ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • 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)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置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])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)