I am filling a datagridview with multiple columns from my oracle database.
It has become necessary that I add a column with a checkbox.
I figured this out.

Dim cbPart As New DataGridViewCheckBoxColumn
                DataGridView1.Columns.Insert(1, cbPart)

                With cbPart
                    .HeaderText = "PART"
                    .Name = "Part"
                    .DisplayIndex = 0
                    .Frozen = True

My column is showing up just fine.
I have a column filled with alphanumeric part numbers for example a154-321-2
I would like to flag a checkbox whenever a part number has a certain format. Such as all formats that contain a154 then check a box.

Can anyone give me a good starting point for this. I am unsure of where to begin.

8 Years
Discussion Span
Last Post by starlight849

You have two options:
first: you can create a extra column in your query to return true or false if your part No start with your criteria, then bound that to the checkboxcolumn.

Second: you have to use the DataGrid.OnItemDataBound Method here is an example then with in that method you will have to compare your format with the part being bound in the datagrid and then check or not your checkbox column.


Thanks for your advice. I'm going to start by attempting to use it within my query. Do you know which method causes less overhead?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.