Click here to Skip to main content
14,937,163 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to have a datalist( type of feature in WinForms as I am doing conversion of a website into Windows application(Note: I am a fresher). e.g. after getting a datatable having details of controls (e.g textboxes checkboxes) parsed to a datalist. It uses "findcontrol" feature of webcontrols and bind the controls to the gridview (website). But I can't predict the working code for win app.

In short I need to bind in a datagridview the controls(e.g checkboxes,textboxes) rather than designing in the forms because there are as many as 100 controls in a form and so I need to bind them from the database.

I don't know how to explain it so please check the image I uploaded which shows how my website grid is bounded with controls from the database.
gridview preview
Updated 24-Jan-11 4:22am
shakil0304003 24-Jan-11 9:12am
not clear!!!

The Winforms DataGridView can be customized to show checkboxes, dropdowns etc., but your requirement seems to include custom layout changes too which may be too much with the DataGridView. If you don't want to fully move to WPF, you might at least want to just write this one control in WPF and then interop with that from Winforms (it will not be trivial, but it will not be too hard either).

On the other hand, if this is a commercial app you are working on, it may make good money-sense to buy the DevExpress XtraGrid which includes a Card View feature which should do what you are expecting (each row would be a card, and you'd configure the card view to look like your screenshot). Even with the XtraGrid it will be some work but it may be far easier than tweaking the DataGridView directly. They do have a trial so you could try it out before deciding if you need to buy it or not.
Espen Harlinn 10-Feb-11 17:49pm
5+, btw: DevExpress DataLayout will allow him to fix this in a minute or two :)
I'd use a grid for navigation - it's way faster than a listbox, and just display the selected record in the layout control. It'll be faster - and probably look much nicer :)
Nish Nishant 10-Feb-11 18:26pm
Ah thanks. It's up to the OP whether he wants to shell out the money (which will be well-spent in my opinion).
I think that to reproduce anything like your image would require you to use WPF[^], rather than WinForms.

Unfortunately WPF doesn't have a GridView so there would have to be some compromise. Perhaps using a heavily customized ListView or just the Grid control.
DreamwithinDream 25-Jan-11 1:37am
could you give some tips on grid control capabilities . thanks for the reply
Member 13066407 22-Mar-17 23:47pm
sir i prepare salebill enter qty wet rate amount in datagrid enter multi row
but row include combobox & chekbox .how handle the combobox and save tata in table without binding sourace
using of third part y tool id the solution i found flexgrid for example which doesn't comes for free . anyway thanks for the suggestions
I do not think that you need a datagrid, I think that what you are looking for is dynamic creation of controls.
Ie for each control you have in your datatable you have code that looks something like this:

Text1 = New TextBox();
        // set up the left and top position (the same as changing the location in the IDE)
        Text1.Left = 100;
        Text1.Top = 100;
        // put an initial value for the text in the box
        Text1.Text = "Hello, I'm new to this form";
        // add the newly created control to the form

Example taken from[^]
There are loads of examples on dynamic control creation on the web.

Of course you would have to use some kind of a variable to set the Left and Top Properties.

I hope this helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900