| S.No | Custom Control | User Control |
|---|---|---|
| 1 | A loosely coupled control w.r.t code and UI. | A tightly coupled control w.r.t code and UI. |
| 2 | Derives from Control. | Derives from UserControl. |
| 3 | Defines UI in a ResourceDictionary. | Defines UI as normal XAML. |
| 4 | UI is skinable. | Child controls are skinable. |
| 5 | Has dynamic layout. | Has static layout. |
| 6 | UI can be changed in different projects. | UI is fixed and can't have different looks in different project. |
| 7 | Has full toolbox support. | Can't be added to the toolbox. |
| 8 | Defines a single control. | Defines a set of controls. |
| 9 | More flexible. | Not very flexible like a Custom Control. |
Custom Control vs User Control
Display Cell Value into ListBox in C#.Net
Add DataGridview,Button and ListBox in your form.
Create one method for getting Particular Cell data for listbox:
DisplayCellDataintoListBox(<Pass Datagridview CellId>);
Create one method for getting Particular Cell data for listbox:
void DisplayCellDataintoListBox(int cellId)
{ foreach (DataGridViewRow row in dataGridView1.Rows)
{ listBox1.Items.Add(Convert.ToString(row.Cells[cellId].Value));
}
}
Call this method in the Button Click event:{ foreach (DataGridViewRow row in dataGridView1.Rows)
{ listBox1.Items.Add(Convert.ToString(row.Cells[cellId].Value));
}
}
DisplayCellDataintoListBox(<Pass Datagridview CellId>);
Labels:
C#.Net