c# - datagridview column index -



c# - datagridview column index -

i have form datagridview widget , need index of column selected name.

for example, let's have table 2 columns: name, surname. need way index of column name. problem changes time depending on datasource column has same name "name".

does know how solve problem?

to retrieve datagridview column name reference through columns collection indexer:

datagridview1.columns["columnname"]

then can column index column:

datagridview1.columns["columnname"].index;

do note if utilize invalid column name reference homecoming null, may want check column reference not null before using it, or utilize columns collection .contains() method first.

c# datagridview indexing

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -