Display hundreds images dynamically

后端 未结 4 1173
北恋
北恋 2021-02-11 05:22

I have to create a form capable of displaying a cinema-hall (don\'t know the exact word) schema. Essentially I have to display a large number (given by another source) of indepe

4条回答
  •  囚心锁ツ
    2021-02-11 05:52

    I'd say that the easiest way would be to create and own "chair-control" which handles it's click event etc. This would be nothing more than a simple User-Defined Control which has the chair image as background (and swaps with other pictures, if necessary).

    After that, you could easily create a big punch of these controls by code (Pseudo-Code):

    for(int row = 0; row < rowMax; row++) {
        for(int column = 0; column < columnMax; column++) {
            this.Controls.Add(New ChairControl(row, column));
        }
    }
    

    The constructor takes the row and column number and automatically adjusts it's position, f.e..

提交回复
热议问题