12.6.2 表格控件
(1)创建表格控件
GtkWidget * gtk_clist_new(gint columns) |
参数含义如下。
columns:表格的列数。
titles:各列的列名。
(2)设置每列的长度
void gtk_clist_set_column_width(GtkCList *clist,gint column,gint width) |
参数含义如下。
column:要设置宽度的列编号,从0开始。
width:宽度。
(3)向表格中加入一行数据
gint gtk_clist_append(GtkCList *clist,gchar *text[]) |
(4)获取和设置表格中某个格子的值
gint gtk_clist_get_text(GtkCList *clist,gint row,gint column,gchar **text) |
(5)清除表格中的所有数据
void gtk_clist_clear(GtkCList *clist) |
(6)对表格中的数据进行排序
void gtk_clist_sort_column(GtkCList *clist, gint column) |
(7)获取和设置一行的数据
gpointer gtk_clist_get_row_data(GtkCList *clist,gint row) |
(8)获取和更改列名
gchar* gtk_clist_get_column_title(GtkCList *clist, gint column) |
(9)插入和删除一行数据
gint gtk_clist_insert(GtkCList *clist, gint row,gchar *text[]) |
例12-6 表格控件的使用,程序名为table.c
#include int main(int argc,char **argv) |
程序运行后的界面如图12-7所示。
![]() |
| 图12-7 运行结果界面 |
