is it possible to filled up data in predifned column using datasource property in dgv
Dear Sir,
I have a Query that is in designe mode I have created 4 columns and formatting 4 columns also in datagrid view control
Viz:- OrderId,OrderNo,OrderDt,OrderAmt
now I want to use datasource of dgv control now when i defining datasource property with table
then dgv control displaying my predefine columnas and adding 4 more columns in dgv for defining datasource.
now presently to avoid autogenerating columns I definie the autogeneration column=false
at this situation if i define datasource=table the no data is come up..
so my query is it is possible to filled up data in predifned column using datasource property.
thanks & regards
Debasis
Re: is it possible to filled up data in predifned column using datasource property in
you can.
Autogerenate coulmn = false.
and in your manually added coulmns set the DataProperty property to the name of the columns of the datasource you're intersted in.
You can set the value of that property as soon as you have the coulumns, even if no datasource has been setted at all.
When you bind the dgv to a datasource, the columns with a datapropertyName that match a column in dataSource will be populated with the data.
So, if in your datasource you have the coulms OrderId,OrderNo,OrderDt,OrderAmt
go to your manually generated coulmns and set
NameOfYourColumn1.DataPropertyName= "OrderId"
NameOfYourColumn2.DataPropertyName= "OrderNo"
NameOfYourColumn3.DataPropertyName= "OrderDt"
NameOfYourColumn4.DataPropertyName= "OrderAmt"
You are not obliged to do this via code, if you designed the cols at design time: go to edit columns through the smartTag of your dgv, select one of your column and see the properties....