简体   繁体   中英

In Winforms what is the easiest way to have a “matrix” (rows of cells) input control?

I have a need to have a user be able to input a matrix. The size will change depending on the users need, but it will be a rectangle, that is symmetrical (Is that the right term?) 6x4 ,10x2,8x8 (All rows will be the same length in a single matrix).

(Its actually not for any matrix "math" manipulation).

I could use multiline text control delimited but I would prefer a grid.

I could use the gridview but it seems to be difficult to use in this manner. I would prefer to make moving around in the grid very easy.

The user will be able to edit the matrix during the processing.

The one thing that makes this difficult is that the user needs to be able to select and delete (or fill (different function)) a rectangle within the matrix. So point at one cell and then drag pointer to highlight a subset of cells.

To clarify a little I used this extraxt from the Emacs user manual

Rectangle commands operate on rectangular areas of the text: all the characters between a certain pair of columns, in a certain range of lines. Emacs has commands to kill rectangles, yank killed rectangles, clear them out, fill them with blanks or text, or delete them. Rectangle commands are useful with text in multicolumn formats, and for changing text into or out of such formats.

I believe you should use the DataGridView control. It suits your requirements best way, imho. Recreate its functionality is much harder than to overcome difficulties with data binding.

在WinForm TableLayoutPanel控件是你需要的: TableLayoutPanel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM