vb.net - hide column in datagridview based on its name - vb.net

Is it possible to hide a column based on the column name?
I know that if I know the column ID, I can use that like so...
TechSearch.Columns(0).Visible = False
I Want to do something like this...
TechSearch.Columns("Details").Visible = False
I've tried that, and the 'Details' column is still visible.
Thanks

This is perfect
TechSearch.Columns("Details").Visible = False
Please just make sure that the datasource is loaded first before hiding the column.
It's good practice to edit/customize your grid on the DataSourceChanged.
From what I imagined is that you are editing the grid before loading the datasource :).

So this is actually correct...
TechSearch.Columns("Details").Visible = False
There was an exception just before this which was causing it not to hide this column.
Thanks all.

Related

Setting a Datagrid Column to read only during run time

I have a datagrid, not a datagridview, where I wan to make a column read only if radio button is checked or not.
So I define the column dynamically from a sql query:
Dim bool_col As New FormattableBoolColumn
bool_col.HeaderText = "Bool Colunm"
bool_col.MappingName = "bool_col"
Also on the form are two radio buttons, lets call them A and B.
When A is checked I want to set the bool_col to read only is true.
When B is checked I want to set the bool_col to read only is false.
Let me know if anything else is needed. I'm using the Click event but I can't figure out how to find the column in the Datagrid and set it to read only. Spent all afternoon trying to do that and searched everything I can think of with no luck.
And I can't change it to a datagridview unfortunately. Time and and money constraints on the project prohibit this.
Thanks in advance!
When you create the column you can add a check:
bool_col.ReadOnly = RadioButtonA.Checked
So the read only property of the column will be true if A is checked and false if A is not.
Now this assumes that your radio buttons are in a group so only one of the two can be checked at a time.
If the radio buttons are not in a group then use:
If RadioButtonA.Checked Then
bool_col.ReadOnly = true
else if RadioButtonB.Checked Then
bool_col.ReadOnly = false
End If

report viewer hide column with external parameter

Need some help on this, when I list Report According to ListBox, All columns are displayed, but I just want to list according to items in ListBox so others columns has to be invisible.
I tried some code = iif(Parameters!TARIH.Value = "True", false,true) but it doesnt work.
Can anyone help me to solve this?
If TARIH is a boolean parameter then you can set column Hidden property like this:
=IIf(Parameters!TARIH.Value, False, True)
Or like this:
=Not Parameters!TARIH.Value
Please note that in rdlc you have to set an Hidden property and not a Visible property.

Make row in listview clickable/selectable vb.net

I have a listview with four columns. I would like the entire row to be selected if someone clicks on one of the elements in the row. Does anyone know how to do this?
Thanks
You probably only need this:
ListView1.FullRowSelect = True

Can we hide VB.NET first selection column?

I hope I state my problem correctly. Kindly please look at the screenclip below :'
I prefer that the first column shown above is not displayed. Is there any design/programmatic way of achieving this?
Thank you!
Edited :
Using this link http://www.andreavb.com/forum/viewtopic_7951.html, I am able to remove the triangle from the selection column
This is using a DataGridView I assume? Just use the visible property for the row headers.
dgv.RowHeadersVisible = false;
Alternatively, you can set it to false using the Properties window.

DataGridView and Combobox Column?

when DataGridView has a combobox column, how can I get the text it displays as oppose to the value it represents? When I do DGV.Item("cbo",i).Value I get the value but it won't take DGV.Item("cbo",i).Text. I trying Ctype(DGV.Item("cbo",i),ComboBox).Text and this does not work either.
Try
DGV.item("cbo",i).DisplayMember
Umm are you talking about Win Forms?
If so, Value is the property you want, and is what is to be displayed on the screen and held behind the scenes.
If you want something different not shown to the user, I've often used the property Tag for that.
I found this, and the answers didn't work for me. In case someone else finds this, here is what I did.
dgv.rows(i).Cells(cboname.index).EditedFormattedValue
Hope if someone finds this through Google it will help them.
Dim dgvcmbcell As DataGridViewComboBoxCell = DgvItemsUnits.Item("UNIT_SER", 0)
Dim SelectedText As String = dgvcmbcell.EditedFormattedValue.ToString()