如何在 C# 中不完全重绘的情况下刷新 tableLayoutPanel?

问题描述

我想填充我在 tableLayoutPanel (25 x 25) 中用鼠标单击的黑色单元格。 现在我通过 mouse_click 事件 cell_paint 事件这样做:

public static void main(String... args) throws IOException {
  ArrayList<String> words = new ArrayList<String>();
  words.add("their");
  words.add("moist");
  words.add("other");
  words.add("blimp");

  Graph g = new Graph(words.size());
  for(String word: words) {
    for(String word2: words){
      g.addEdge(words.indexOf(word),words.indexOf(word2));
    }
  }

  BufferedReader readValues = null;

  try {

    readValues =
        new BufferedReader(new InputStreamReader(new FileInputStream("testfile.txt")));

    String line = null;
    while ((line = readValues.readLine()) != null) {
      // assert line.length() == 11;
      String[] tokens = line.split(" ");
      String start = tokens[0];
      String goal = tokens[1];

      BreadthFirstPaths bfs = new BreadthFirstPaths(g,words.indexOf(start));
      if (bfs.hasPathTo(words.indexOf(goal))) {
        System.out.println("Shortest path distance from " + start + " to " + goal + " = " + bfs.distTo(words.indexOf(goal)));
      } else System.out.println("nothing");
    }

  } finally {
    if (readValues != null) {
      try {
        readValues.close();
      } catch (Throwable t) {
        t.printstacktrace();
      }
    }
  }

我只是创建了一个 Color 类的二维数组,这个数组中的所有元素都等于 SystemColors.Control。并且,当我单击 tablelayoutpanel 中的单元格时,mouse_click 事件中的算法会将我单击的单元格位置发送到 Color 类的二维数组。并且,在tableLayoutPanel中点击的array中的元素等于二维数组中的元素,所以array中的这个元素等于Color.Black。所以,在那之后,我调用 tablelayoutpanel 的刷新事件,我的表通过我的数组方案重绘。 所以,我面临的问题是,每次单击鼠标后,我的表都会调用完整的重绘。我想删除它。我该怎么做?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)