C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Need - DataGridView - Combo Box, Check Box Example


Posted Date: 04 Dec 2008      Posted By: Pankaj Prajapati      Member Level: Bronze     Points: 1   Responses: 6



hi....

we have developed windows application using C#.Net 2005

we want to use Combo Box, Check Box controls in DatagridView as columns,

before it there is three columns which comes from database, so i have used DataBinding concept for with DatagridView, but now how can map my last 2 columns Combo Box and Check Box with that first three columns...

i need urget solutions... hope any one can help me....

thanking you....

pankaj prajapati
98790 98469





Responses

Author: ani    04 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 4

hi
This ths the sample coding try like this...

DataGridViewCheckBoxColumn chkbx_key = new DataGridViewCheckBoxColumn();

//Use this coding when u want the control to bind in Datagridview..

chkbx_key = new DataGridViewCheckBoxColumn();
chkbx_key.Width = 40;
chkbx_key.FlatStyle = FlatStyle.Popup;
chkbx_key.HeaderText = "Key";
chkbx_key.DisplayIndex = 2;
datagridview_ParaUnit.Columns.Insert(3, chkbx_key);

Same as ComboBox..
regards
ani



Author: ani    04 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 4

hi
This ths the sample coding try like this...

DataGridViewCheckBoxColumn chkbx_key = new DataGridViewCheckBoxColumn();

//Use this coding when u want the control to bind in Datagridview..

chkbx_key = new DataGridViewCheckBoxColumn();
chkbx_key.Width = 40;
chkbx_key.FlatStyle = FlatStyle.Popup;
chkbx_key.DisplayIndex = 3;
datagridview_ParaUnit.Columns.Insert(3, chkbx_key);

here datagridview_paraUnit is DatagridView name..
Same as ComboBox..
regards
ani



Author: Pankaj Prajapati    04 Dec 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

hi thanx for this... solution...

it is working well...

but can u tell me how can i use it with multiple columns
in datagridview that r bind using DataBind method.....

thanx....



Author: ani    04 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 5

here i am using two check boxs and one combobox.. Hope this s wt u expects

DataGridViewCheckBoxColumn chkbx_key1 = new DataGridViewCheckBoxColumn();
DataGridViewChomboboxColumn combobx_key2 = new DataGridViewChomboboxColumn();
DataGridViewCheckBoxColumn chkbx_key3 = new DataGridViewCheckBoxColumn();


chkbx_key1 = new DataGridViewCheckBoxColumn();
chkbx_key1.Width = 40;
chkbx_key1.FlatStyle = FlatStyle.Popup;
chkbx_key1.DisplayIndex = 3;
dgv_ParaUnit.Columns.Insert(3, chkbx_key1);

combobx_key2 = new DataGridViewChomboboxColumn();
combobx_key2.Width = 40;
combobx_key2.FlatStyle = FlatStyle.Popup;
combobx_key2.DisplayIndex = 4;
dgv_ParaUnit.Columns.Insert(4, combobx_key2);

chkbx_key3 = new DataGridViewCheckBoxColumn();
chkbx_key3.Width = 40;
chkbx_key3.FlatStyle = FlatStyle.Popup;
chkbx_key3.DisplayIndex = 5;
dgv_ParaUnit.Columns.Insert(5, chkbx_key3);



Author: Pankaj Prajapati    08 Dec 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 0

hi. ani

h r u?

thanx for this gr8 solution.....



Author: Pankaj Prajapati    10 Dec 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 4

hi...

again thnx...

i have tried ur solution, it is working very well...

but i want to do like this...

i have filled my datagridview like this...

dt = SqlHelper.ExecuteDatatable(SqlHelper.ConnectionString, CommandType.Text, "Select MId, MName From ModelM Order BY MName");
dtGrdVw.DataSource = dt;
dtGrdVw.Columns[0].Width = 0;
dtGrdVw.Columns[0].Visible = false;
dtGrdVw.Columns[1].Width = 197;
dtGrdVw.Columns[1].HeaderText = "Code";
dtGrdVw.Refresh();


now i want put checkboxes against MName field....

so how can i do this.... plz give me a soltuion for this....

thanking u.....



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Getting XML from an aspx querystring url
Previous : Spring.NET
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use