Hello :)
Im wondering if you could help me... Well, I would like to get data from SfDataGrid,
i have tabel with ID, Name and Surename.
for example
ID NAME SURNAME
1 |Sara |S
2 |George |G
When the user is going to click on ID 1 or Name Sara
Label will be field with those values.
Do you have any idea?
|
private void SfDataGrid_CellClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e)
{
if (sfDataGrid.CurrentCell != null)
{
// Get the row index value
var rowIndex = e.DataRow.RowIndex;
//Get the column index value
var columnIndex = e.DataColumn.ColumnIndex;
//Get the cell value
label2.Text = this.sfDataGrid.View.GetPropertyAccessProvider().GetValue(e.DataRow.RowData, e.DataColumn.GridColumn.MappingName).ToString();
}
} |
Thanks
but I tried it like that already, i this case i get only one value,
but I need it like that: if i click on id 1 or name Sara
I get in label1 text: 1 (as an ID)
in label2 text : Sara (as a name)
and in label3 text: S (as surname)
I know how to do it in datagridview but in Sfdatagrid its different
if you could help me with this case i would really appreciate that
|
sfDataGrid.CellClick += SfDataGrid_CellClick;
private void SfDataGrid_CellClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e)
{
label2.Text = this.sfDataGrid.View.GetPropertyAccessProvider().GetValue(e.DataRow.RowData, "OrderID").ToString();
label5.Text = this.sfDataGrid.View.GetPropertyAccessProvider().GetValue(e.DataRow.RowData, "CustomerID").ToString();
label6.Text = this.sfDataGrid.View.GetPropertyAccessProvider().GetValue(e.DataRow.RowData, "CustomerName").ToString();
} |
|
private void button1_Click(object sender, EventArgs e)
{
var selectedItem = this.sfDataGrid.SelectedItem;
label2.Text = this.sfDataGrid.View.GetPropertyAccessProvider().GetValue(selectedItem, "OrderID").ToString();
label5.Text = this.sfDataGrid.View.GetPropertyAccessProvider().GetValue(selectedItem, "CustomerID").ToString();
label6.Text = this.sfDataGrid.View.GetPropertyAccessProvider().GetValue(selectedItem, "CustomerName").ToString();
} |
|
this.sfDataGrid1.AutoGenerateColumns = true;
var table = this.GetDataTable();
sfDataGrid1.DataSource = table;
ReportViewer reportViewer1 = new ReportViewer(); //Your ReportViewer Control
ReportDataSource rds = new ReportDataSource("ProgrammersDataSet", sfDataGrid1.DataSource);
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.LocalReport.Refresh();
reportViewer1.LocalReport.ReportEmbeddedResource = "Cerocha.Presentation.Reports.ProgrammersReport.rdlc";
reportViewer1.LocalReport.Refresh(); |