Custom Control Property
-
I have a control that includes a few buttons, a drop down and a text box. There is a property called DestinationGrid which is set at design time to be the grid the control works with. I also have another property called SelectedRow which is used to set the on the grid. Because the grid doesnt have any rows I get an error when I view the form at design time saying that SelectedRow - Object not set to an instance ... How can I stop thsi error occuring? I could remove the property and use a SetSelectedRow() and GetSelectedRow() method, but would like to use a property. Any suggestions? Thanks
-
I have a control that includes a few buttons, a drop down and a text box. There is a property called DestinationGrid which is set at design time to be the grid the control works with. I also have another property called SelectedRow which is used to set the on the grid. Because the grid doesnt have any rows I get an error when I view the form at design time saying that SelectedRow - Object not set to an instance ... How can I stop thsi error occuring? I could remove the property and use a SetSelectedRow() and GetSelectedRow() method, but would like to use a property. Any suggestions? Thanks
Write a intialiser in your custom class constructor. That means, in your custom control constructor you have to initalise the selected row value if the datagrid is selectable. To check whether datagrid is selectable use this
dataGrid1.CanSelect
property . If it is selectable then it will return true else will return false. This is only a small idea to handle the situation. Sreejith Nair [ My Articles ]