Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataGridView and TabControl bug?

$
0
0

I've come across some odd behavior involving DataGridView controls and TabControls. Have I stumbled across a bug, or is there something I don't understand about these controls?

My app uses a TabControl with five TabPages. Each TabPage has its own DataGridView, which I bind to DataTables in the main window's FormLoad event. I  set the HeaderText property of each column of the DataGridViews at run time, because I don't know in advance what the columns will be. I get the header text from the DataColumn Caption properties in my DataTable.

Data binding works fine on all grids, as do other properties, such as caption alignment for the DataGridViewColumns. But the HeaderText assignment only works for the grid on the first TabPage. The assignment works on the other grids only if I first activate theier TabPage. (For debugging purposes, I wired the HeaderText assignments to the TabPage click events).

So it looks like HeaderText property is settable only if the DataGridView is on the active TabPage. Which brings me to my question: Is this behavior a bug, or by design? How to I go about setting (at run time) the column headers of DataGridViews on TabPages? Thanks in advance.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>