boondoggle

Hello,

I have a datagridview and it is databound to a dataset which is retrieved from the db. Now, I clicked on the datagridview visual editor and it said "edit" , "add" columns. I clicked on "add" and then proceeded to create a unbound datagridviewbuttoncolumn. I set the text property of said button, I have the flat cell set to standard instead of popup. I even tried modifying the defaultcellstyle property sheet but to no avail. I then decided to add any datagridview control (link, button, etc) from within the visual editor and was unable to see any text in that column. I even added 4 extra columns of datagridviewbuttoncolumn's and did not see any text on any of the buttons.

However, when I manually added the code and did not rely on the visual editor, everything worked like a charm and as it should be. Could someone please explain to me how come I am not able to see the text on the datagridviewbuttoncolumn when using visual editor but can when writing code manually. When I use the visual editor, all I see is a white blank button with no text.

cheers

Boon



Re: Windows Forms Data Controls and Databinding datagridviewbuttoncolumn text missing problem

Zhi-Xin Ye - MSFT

Hi,boondoggle

You have to set the UseColumnTextForButtonValue to true in the visual editor or in code.

Regards.

Ye.






Re: Windows Forms Data Controls and Databinding datagridviewbuttoncolumn text missing problem

boondoggle

thanks for responding but that does not work. I have already tried that and also what if you dont want the button to have same text as the column

cheers

Boon





Re: Windows Forms Data Controls and Databinding datagridviewbuttoncolumn text missing problem

Zhi-Xin Ye - MSFT

Do you mean you don't want the buttons in the column to have same text as the column header, or you want the buttons in the column to have different textes

Regards.

Ye






Re: Windows Forms Data Controls and Databinding datagridviewbuttoncolumn text missing problem

boondoggle

It really doesn't matter but I have tried changing this property value and it did not help. there was still no text on the button.

cheers

Boon





Re: Windows Forms Data Controls and Databinding datagridviewbuttoncolumn text missing problem

Zhi-Xin Ye - MSFT

Really It works well here on my IDE, I'm using VS 2005 VSTO. I just add a datagridviewbuttoncolumn to the DataGridView, and for example set the text to "aa", and set UseColumnTextForButtonValue to true , and while running, "aa" is displayed on the buttons.

Regards.

Ye






Re: Windows Forms Data Controls and Databinding datagridviewbuttoncolumn text missing problem

zbo

suppose your button column in first column

just add follow sentence when you ini your datagridview

((DataGridViewButtonCell)this.dataGridView1.Rows[0].Cells[0]).Value = "button";

it cause the first row, first column's button's text show "Button" en:)






Re: Windows Forms Data Controls and Databinding datagridviewbuttoncolumn text missing problem

boondoggle

I did not make myself clear.  I used the gui visual designer to drag a datagridview on the form.  I then clicked on the little arrow in left hand corner and it popped open a menu.  In this menu you can setup your databinding with stored procedures and etc.  I then proceeded to setup a datasource for two columns, tempA, tempB.  Now both tempA and tempB were databound with a dataset, tableadapter and bindingsource--all created by the visual designer.  I then from within the form code call                      

Sp_GetErrorsTableAdapter.Fill(Me.dsGetErrors.sp_GetErrors, myvar)  to populate tempA and tempB that i created with the visual designer.  Now after testing that this returned the data in the two columns i wanted, i then went back to the visual designer of the datagridview and decided to add another column.  this time i added a datagridviewbuttoncolumn.  However, since adding this new column, the button text would not appear.  I also unchecked allow add, allow edit, and allow delete from within the datagridview visual designer.  I do not want the user messing with the datagridview.  Now when I run it the datagridviewbuttoncolumn does not have any text on it.   

therefore, my question is does the line of code above when i fill the tableadapter cause other columns to be messed up  

The reason for using  Sp_GetErrorsTableAdapter.Fill(Me.dsGetErrors.sp_GetErrors, myvar)  was to pass a parameter to my stored proc after designing it in the visual editor.

Hope this helps you understand my problem.

 

cheers

Boon

 

 





Re: Windows Forms Data Controls and Databinding datagridviewbuttoncolumn text missing problem

Delux

I assume you got this figured out, but for anyone following behind, it's the GUI playing tricks with your mind. When using the Edit Columns toolbox (which is drawn too small to be useful, use bottom-right grab to expand it to a reasonable size), you must set the UseColumnTextForButtonValue = True just like mentioned above for your DataGridViewButtonColumn. However, read carefully, it is not the HeaderText that it will copy, but the actual Text in the colum. You can place text in the column by putting something in the Text attribute of the DataGridViewButtonColumn in the Edit Columns toolbox. I just spent 45 minutes trying to figure this out b/c I left the Edit Columns toolbox too small to see the entire attribute name and realize what it meant.