|
-
February 27th, 2012, 01:59 AM
#1
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
-
February 27th, 2012, 09:14 AM
#2
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....
Last edited by Cimperiali; February 27th, 2012 at 09:19 AM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|