我有一个Windows窗体datagridview.
理想情况:
用户点击九列中的任何一列,程序会对所有数据进行排序,如果点击的列包含数字,我希望顶部的数字最小.如果单击的列包含一个字符串,我希望它按字母顺序排序(AZ).
我现在拥有的:
我在Stack Overflow上看到了一个老问题,OP在点击"a"标题时如何对datagridview进行排序.与我的不同之处在于我希望我的datagridview可以通过九列中的任何一列进行排序.
我有这个代码,从我发现的问题中窃取:
dataGridView2.DataSource = listPlayers.Select(s => new { voornaam = s.Voornaam,
Achternaam = s.Achternaam,
positie = s.Positie,
Nationaltieit = s.Nationaliteit,
Leeftijd = s.Age,
Aanval = s.Aanval,
Verdediging = s.Verdediging,
Gemiddeld = s.Gemiddeld,
waarde = s.TransferWaarde })
.OrderBy(s => s.Achternaam)
.ToList();
foreach(DataGridViewColumn column in dataGridView2.Columns)
{
dataGridView2.Columns[column.Name].SortMode =
DataGridViewColumnSortMode.Automatic;
}
Run Code Online (Sandbox Code Playgroud)
这只允许用户在点击九列中的一列时通过"Achternaam"订购.我想要的是当用户点击Nationaliteit列时,数据按An排在最前面.每个专栏都是如此
这是列表播放器列表:
namespace SimulatorSimulator
{
class SpelerData
{
public string Voornaam { get; set; }
public string Achternaam { get; set; }
public string …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Jackson的ObjectMapper将以下Player对象写为String。
package models.Game;
import models.Game.Enums.SnowballState;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import java.util.ArrayList;
import java.util.List;
public class Player {
private Circle circle;
private String name;
private Color color;
private int points = 0;
public int getLives() {
return lives;
}
private int lives = 3;
private List<Snowball> snowballs;
private Circle oldCircle;
private int stepSize = 10;
public Player(String name, Color color) {
this.name = name;
circle = new Circle();
oldCircle = new Circle();
this.color = color;
snowballs = new ArrayList<>();
snowballs.add(new Snowball(this)); …Run Code Online (Sandbox Code Playgroud) 我有以下Javascript代码.由于某种原因,ajax成功选项触发两次,我得到两个相同的警报.
if (message =="") {
$.ajax({
url: '/dev/php/register.php',
type: 'POST',
data: {firstname:voornaam,lastname:achternaam,email:email,password:wachtwoord,gender:gender,date:datum},
success: alert("Account aangemaakt")
})
}
else {
showSnackBar(message);
return false;
}
Run Code Online (Sandbox Code Playgroud) 我正在进行单元测试以测试我编写的算法,不幸的是,由于此错误,这些测试甚至无法运行:
[10-6-2018 00:12:00 Informational] ========== 运行测试完成:0 运行 (0:00:06,5685302) ========== [10 -6-2018 00:12:04 信息] ------ 运行测试开始 ------ [10-6-2018 00:12:09 错误] 活动测试运行已中止。原因:进程因 StackOverflowException 而终止。
这些都是我的单元测试:
namespace AlgoritmeTest
{
[TestClass]
public class AlgoritmeTests
{
[TestMethod]
public void TestAddingWagonToTrain()
{
Train train = new Train();
Wagon wagon = new Wagon(10);
List<Wagon> expected = new List<Wagon>();
expected.Add(wagon);
train.AddWagon(wagon);
List<Wagon> actual = train.GetWagons();
Assert.AreEqual(expected, actual, "Failed to add wagon to train");
}
[TestMethod]
public void TestAddingAnimalToWagon()
{
Train train = new Train();
Wagon wagon = new …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习javascript,现在购买当我尝试重复一个功能时,它似乎无法正常工作.
这是我的功能:
function heyhey(el){
el.style.position = "absolute";
el.style.top = Math.floor(Math.random()*document.body.clientHeight);
el.style.left = Math.floor(Math.random()*document.body.clientWidth);
}
heyhey(document.getElementById('random'));
//random is the id of my html div
Run Code Online (Sandbox Code Playgroud)
这有效,但我希望每秒调用一次这个函数
我试图重复这个功能:
function heyhey(el){
el.style.position = "absolute";
el.style.top = Math.floor(Math.random()*document.body.clientHeight);
el.style.left = Math.floor(Math.random()*document.body.clientWidth);
heyhey();
}
heyhey(document.getElementById('random'));
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
function heyhey(el){
el.style.position = "absolute";
el.style.top = Math.floor(Math.random()*document.body.clientHeight);
el.style.left = Math.floor(Math.random()*document.body.clientWidth);
setTimeout(heyhey, 5000);
}
heyhey(document.getElementById('random'));
heyhey();
Run Code Online (Sandbox Code Playgroud) c# ×2
javascript ×2
ajax ×1
datagridview ×1
function ×1
jackson ×1
java ×1
javafx ×1
jquery ×1
unit-testing ×1