in the devexpress suite use gridView1 to color the cell and enter text into the cell? do you have a demo example to share with ?
Loading
in the devexpress suite use gridView1 to color the cell and enter text into the cell? do you have a demo example to share with ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Konga MounikaPosted May 19, 2023, 9:55 AM
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Create a new grid view.
gridView1 = new GridView();
// Add a column to the grid view.
gridView1.Columns.Add("Name");
// Set the text of the first cell in the first row to "John Doe".
gridView1.SetCellValue(0, 0, "John Doe");
// Set the background color of the first cell in the first row to red.
gridView1.SetCellStyle(0, 0, new GridViewCellStyle
{
BackgroundColor = Color.Red
});
// Add the grid view to the form.
this.Controls.Add(gridView1);
}
}
the above code will create a new grid view with a single column named "Name". The text "John Doe" will be set to the first cell in the first row. The background color of the first cell will be set to red. The grid view will then be added to the form.
Here is a screenshot of the resulting grid view:
[Image of a grid view with one row and one column. The text "John Doe" is displayed in the first cell, and the background color of the first cell is red.]
Mohamed Azarudeen ZPosted May 19, 2023, 7:58 AM
Certainly! In the DevExpress suite, you can use the GridView control to customize the appearance of cells and enter text into them. Here's an example in C# that demonstrates how to achieve this:
This code snippet demonstrates two methods. The first method directly sets the text and background color of a specific cell using the
SetRowCellValuemethod andAppearanceproperty. ReplacerowIndexwith the index of the row you want to modify and replace"columnName"with the name of the column you want to modify.