Form inheritance improve our coding time. But I'm facing a problem while inherit a form that contain DataGridView control. I could not modify the DataGridView properties. Eventhough change the modifier property to protected or public. The DataGridView control still locked in designer.
Here a brief step to work with:
1. I add a new class file for example FerDataGrdView.cs in my library objects (mylib.dll).
2. Type this code:
using System.Windows.Forms;
using System.ComponentModel;
namespace Ferryptk
{
[Designer(typeof( System.Windows.Forms.Design.ControlDesigner))]
public class FerDataGrdView : DataGridView { }
}
3. Build library (mylib.dll).
4. Add reference to mylib.dll
5. Drag the control (FerDataGrdView) in ancestor form.
6. Do form inheritance.
7. Now, I could modify the properties of DataGridView control.
O.. happy day..
Sabtu, 01 Mei 2010
Unlock DataGridView properties in Inherited Form
Langganan:
Posting Komentar (Atom)
saya sudah coba, dan memang coding tersebut memungkinkan kita untuk mengakses property dlm form turunannya, akan tetapi, saya tidak menemukan property "items" yg berfungsi untuk mengedit kolom dlm datagrid.....apa ada yg perlu di tambahan khan dalam library ?
BalasHapusups,ga jadi deng :p
BalasHapussalah, nama propertynya columns...=))
ok...moga lancar :)
BalasHapus