DataGridView Ensures Application Consistency

In our application, we will have several search dialogs. The UI is simple (textbox, datagridview result, ok button, cancel button). The only real change between the various dialogs is the label text and the grid anchor source. We want to enforce certain properties (like full line selection and read-only mode) and events (like click and double-click) so that when someone wants to add a dialog, we know the user will get consistent behavior because this the dialog implements the same properties and events that are implemented in every other dialog box in our application.

I created a basic crawler form that hosts some properties and ok / cancel buttons + their click events. I am stuck with datagridview. What would be the best approach to ensure that all datagridviews have similar characteristics in one of our search dialogs?

0


a source to share


2 answers


Today I have implemented a custom grid (DataGridViewFinder) that descends from the DataGridView. This grid is specific to our search dialogs only. The grid has default properties set to match all of our other search networks. Also, since I know this type of grid will only be in the finder dialog, I have overridden some events that will set properties and call methods on the base finder.

I like this approach because it ensures that when I delete my custom grid in the search dialog, certain properties and events are already handled for me. There will be many search dialogs and I suspect this will save a lot of time. Does anyone see something wrong with this implementation?



protected override void OnEnter(EventArgs e)
{
    base.OnEnter(e);
    if (Parent is BaseFinder)
    {
        (Parent as BaseFinder).Mode = FinderMode.Ok;
    }
}

protected override void OnDoubleClick(EventArgs e)
{
    base.OnDoubleClick(e);
    if (Parent is BaseFinder)
    {
        (Parent as BaseFinder).btOk_Click(this, e);
    }
}

      

0


a source


If the only difference between the various dialogs is the text of some label and datagridview binding source, why not just use the same shape for all dialogs? You can easily get a form that reveals properties through which you can control these differences.



+2


a source







All Articles