CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    3

    Lightbulb DataGridview form inheritance property visibility (csharp)

    Hello Sir

    Im new to c Sharp but Iam already a programmer of a few lanaguage for win32 and web.

    Now Iam trying to create a application framework in csharp.net (using vs2005) win32 and i run into some problem on inheriting the grid property from a base form object. The situation is.

    1. I created a base form with DataGridview, dataset, bindingnavigator, and bindingsource. making thier modifiers as protected which makes their property visible to the inheritance form. the functions that will make up for this form like search open, edit and etc is can be place here.

    2. I created a inheritance form from this base form, with this I can just put a dataadapter I just created and set it to my bindingnavigator control, ok it works.

    3. THE PROBLEM. I cannot set the property column collection in the design to set the datagridview in the inhereted form. as you know if I have to use this base form it is only natural for it to have a different columns, width, etc.

    -> I need to make atleast the column collection to be accesible in design time to change it on every new inhireted form.

    -> or I need to make some control object column collection that will be place in the inhireted form that points in the current dataadapter, which i can modify the property in design time, and set it to point in the datagrid column property in my Inhereted form InitializeComponent().

    I hope you give give me a tip or two.

    Thanks in advance.

  2. #2
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: DataGridview form inheritance property visibility (csharp)

    can you explain what is column collections here ? Is it specific to the datagrid columns or some other component you have created seperately and trying to add it to the datagrid inherited from the base forrm,.

  3. #3
    Join Date
    Oct 2009
    Posts
    3

    Smile Re: DataGridview form inheritance property visibility (csharp)

    Thanks for the reply,
    I will explain this more in details
    dont get me wrong I know csharp.net is already a framework (why are you creating application framework from it?)
    but I need my code to be simple as just passing a parameter and you have a new listform in a flash well you know what I mean.

    What I want to achive:
    - Created a Base View Form with DataGridView, Navigator a few Buttons for search and open
    - In this form is I can add a functionality to call the another form for edit and new,etc. via param below
    - I can Inherit a form from this and pass only the ff in the inhireted form
    - Dataadapter to the binding source and thats it.
    - FormObject to be called for edit and new

    This is what I have done.
    1. I created a BaseForm lets call this a ViewForm. in it,
    - BindingNavigator (with a toolstrip button for First,Prev,Next,Last, delete, Open)
    - I plan to have a search field here too. and etc
    - DataGridView
    - BindingSource
    - Dataset
    - Note this will run on itself with data it a dataadapter is added (you know how it works. ok)

    2. I created/inhiret the form called (ViewEmployees)
    - I added a dataapter and bind it to the binding source ( ok now the grid has its columns)
    - create an instance past the form param for new, edit Run this and its fine its working good.

    Notes. we all know that if I edit the "BASE FORM" and added the dataadapter for let say an emplyess table
    it will run smoothly, and if I want to remove a column or change a property of the column of the "dataGridview"
    I would simple click the column collection of the "dataGridview" and set each column property as I see fit.

    The Problem.
    - On the Inhireted Form after setting the dataapdapter and the grid column gets populated,
    I cannot change the "dataGridview" column collection property all the Grid property is grade as if it is a read only
    I tried changing the grid property modifier to (protedted,public) from the baseform and it is still read only
    in the inhireted form.

    What I want to accomplish
    How can I make the column property of the grid from baseform NOT READONLY when editing it in designmode from my (ViewEmployees) form
    is it posible? so that whenever I use the baseform and use a differect dataadapter I can also set the grids clumn properties.
    Pls help.

    I also tried this.
    - I created a new Control with the ff Property
    - ColumnProperty (DataGridViewColumnCollection)
    - DataGridView (System.Windows.Forms.DataGridView) and the following code
    public System.Windows.Forms.DataGridView DataGridView
    { get
    { return _DataGridView; }
    set
    { _DataGridView = value;
    _Columns = _DataGridView.Columns;
    }
    }
    - I place this new control in (ViewEmployees)
    - I tried to change the DataGridView property
    - when I click the column property of the Usercontrol ( ok it works it populated my columns in the usercontrol)
    - The Problem here is the columns it added is readonly and I cant see any property for each column in the datagrid collection editor
    - I can add and remove a new columns and change its property.
    - but What I need to do is change the column property that point to my grid.

    That its this is all my progress I hope you/anyone could help me out.
    Thanks in advance.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured