c# - DatagridviewButtonColumn is visible to every row when click on a cell of row/column -


i have datagridview has text box columns.in datagridview have added datagridviewbuttoncolumn after third column , have set visible = false shown in below code.

datagridviewbuttoncolumn btnellipse = new datagridviewbuttoncolumn();  btnellipse.text = "..."; btnellipse.fillweight = 6; btnellipse.minimumwidth = 20; btnellipse.width = 20; btnellipse.dividerwidth = 0; //btncompanyproperty.headertext = "to company/property"; btnellipse.usecolumntextforbuttonvalue = true; dgvforecast.columns.insert(4, btnellipse); dgvforecast.columns[4].visible = false; dgvforecast.columns[dgvforecast.columns["basevalue"].index + 1].autosizemode = datagridviewautosizecolumnmode.allcells;  dgvforecast.columns[dgvforecast.columns["basevalue"].index + 1].width = 20; dgvforecast.columns["basevalue"].headercell.style.alignment = datagridviewcontentalignment.middleright;  dgvforecast.columns["basevalue"].celltemplate.style.alignment = datagridviewcontentalignment.middleright; 

now problem have show button cell when click on index 3 cell.now showing full button column when click on index 3 cell shown in below image.i want show selected row button cell not full button column.

enter image description here

i want when click on first row value cell first row button cell should visible , when click on second row value cell first row button should invisible , current row button should visible.

you can't hide specific cells in datagridview. there no direct support in datagridview.

one way of doing create custom datagridviewbuttoncolumn control visibility using custom property , override paint method draw rectangle background color when property set. similar available in msdn forum question removehide-button-on-datagridview.

using above custom column make cell visible in cellenter/rowenter event , hide in cellleave/rowleave event.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -