C# Datagridview Customisation – Part Of Larger Project

I have a windows form with 2 datagridviews in c# but I need it to have the following features.

Both datagridviews are similar in function:
Unbound – not linked to any data source.

Two columns:-

Column 1: contains a number from 1 – 255 ( Zero not allowed but may be in future – disallow for now).

Column 2: contains plain text.

Datagridview1 Column Names “Area” , “Area Name”
Datagridview2 Column Names “Zone” , “Zone Name”

Column sorting on column 1 ( Area / Zone ) must be in numeric order ( not string based ).

User must be able to add rows by entering a new number and optionally adding text in column 2.

Duplicate numbers are not allowed. – If a duplicate number is added manually then message box prompt ‘ Duplicate’ . No action until user corrects it – or cancels the operation.

Not allowed to have text in column 2 without a valid number in column 1 – if text added, then focus will then move to the number cell awaiting a valid number ( or a cancel operation ). If cancelled – the row will be deleted.

There must be a function provided to programatically add rows with new unique numbers ( function returns ‘true’) – if duplicate number found, function will return without doing anything ( and return a ‘false’ value).

The user must be able to delete rows. ( Delete on Keyboard or Right Click ‘Delete’ on Row )

There must be a function to programatically delete rows ( based on the unique number in column 1. If attempt to delete a non existent row then the function returns ‘false’.

The tables will never have more then 255 rows.

Leave a Reply

Your email address will not be published. Required fields are marked *