Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Simple binding c# 2005 very strange problem (bet you cant solve it!)
 

Simple binding c# 2005 very strange problem (bet you cant solve it!)

Hey guys,

I am dynamically building a datagridview and above each of the columns there is going to be a combobox which allow the datagridview to be filtered. The columns of the datagridview are going to be resizeable and so i need the combobox's above each column to resize as well. I can do this programatically but i wanted to use Data binding, my thoughts were it was really basic and here are the lines to do it....

ComboBox theFilter;

DataGridViewTextBoxColumn theColumn = new DataGridViewTextBoxColumn();

theFilter.DataBindings.Add("Width", theColumn, "Width");

If you can please tell me why this isn't working that would be great. What i have noticed is:

1. If i set the column.width = x, then the combobox will resize only once i leave clicked in the combobox and leave it.

2. If i resize the column by clicking on the column divider and dragging it when i click in the combobox and leave it the column resizes.

Cheers

Kris

Kmad  Friday, May 12, 2006 2:04 PM

It seems that no events are raised on the column when the Width property is changed, so the databinding doesn't work (it just responds to a PropertyChanged event). However, you can handle the ColumnWidthChanged event on the DataGridView and change the width of your ComboBox manually with just a few lines of code.

Tony

tkerns  Friday, May 12, 2006 3:23 PM

This is the first time doing a project in.netand i understand the concept behind data binding but just wanted to use it. I am currently resizing it manually with a few lines of code.

Cheers though

Kris

Kmad  Monday, May 15, 2006 8:17 AM

You can use google to search for other answers

Custom Search

More Threads

• How to prevent leaving an empty cell in a DataGridView ?
• While scrolling within a datagrid, it loses foces ? Could this be a bug?
• how to execute 2 or more sql statements in one step in oracle
• System.ArgumentException: This row already belongs to another table.
• datagrid displaying '+' sign
• Datagrid begin edit problem (bug)?
• how to select datagridview cell
• Editable/Hierarchical List
• DataGridView - BeginUpdate
• How to Merge databases