简体   繁体   中英

fill specific column gridcontrol devexpress

I want to fill a specific column in a gridview. I want to do this with code, but I have already established the column in the gridcontrol as how you can see in the picture.

established Column

This is my code to fill the column, but I don't know what to do to fill that specific one column using name or fieldname or whatever it takes.

GridControl1.DataSource = Nothing

SQL.ExecQuErY("SELECT nombre FROM productos")

If Not String.IsNullOrEmpty(SQL.Exception) Then MsgBox(SQL.Exception) : Exit Sub

For Each row As DataRow In SQL.DBDS.Tables(0).Rows

        ?????? THIS IS WHERE IT'S SUPPOSED TO GO THE INSTRUCTION TO FILL THE COLUMN ??????

Next

Refer this answer on another SO thread.

How to add new line of row in devexpress gridcontrol?(WinForms C#)

It may direct you to correct way of implementation. You must have some backing data source assigned to grid control to add row at run time and assign only the one column value to the grid using the SetRowCellValue method.

There are lots of question on DevExpress support related to such implementation. Please follow the below references:
Creating Columns and Binding Them to Data Fields
ColumnView.AddNewRow Method
Add new row to xtragrid through code Add New Row to GridView
Adding new row to gridview
Adding gridView columns at runtime GridView: Add column in runtime
how to add columns to xtragrid dynamically at runtime and also how to add repository items to those columns dynamically??

Hope this help..

Try to bind the data to your grid like this :

Sql.ExecQuErY("SELECT nombre As colNombre FROM productos")
GridControl1.DataSource = Sql.DBDS.Tables(0)

FieldName of column in GridControl must have same name of Field in DataSource .

or you can change FieldName of column in GridControl to nombre and use your initial query :

Sql.ExecQuErY("SELECT nombre FROM productos")
GridControl1.DataSource = Sql.DBDS.Tables(0)

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