VirtualTreeview enabling and disabling columns - delphi

I have a VirtualTreeView which has some columns initially hidden (coVisible is not present).
After enabling them (adding coVisible to the column Options) a strange thing happens - column appears but overlaps with previous column. I can fix the problem by changing width to 1 pixel smaller, then back to original width of the column which forces some repaint which then displays column correctly.
Is there something I need to do additionally except adding coVisible to make the columns repaint properly?

Use:
VTV.Header.Columns.BeginUpdate;
try
// Enable or Disable columns...
finally
VTV.Header.Columns.EndUpdate;
end;
This should keep the Header.Columns in sync.

Related

Hide Horizontal Scrollbar from TListView

I am facing a strange problem when removing the horizontal scrollbar from TListView.
procedure TForm1.listDataResize(Sender: TObject);
begin
ShowScrollBar(listData.Handle, SB_HORZ, False);
end;
When using down or up arrow keys, then Column header Second and beyond is erased, when i resize the column manually then it is displayed back. When i remove the code from listDataResize then this problem no more occurs.
I just want to remove the horizontal scroll-bar from appearing in the ListView. As above code is working fine, the only thing bothering me is why second and beyond column headers are erased.
I don't know why it was happening, I deleted the current form holding TListView and created a new Form not touched any property of the form except Caption of the form and dropped the TListView once again.
ListView.RePaint;
ListView.Refresh;
Now it is no-more erasing the column header. I have not touched any property like double buffering etc. Working good.

How do you set the Delphi ListView.Columns[0] to be right justified?

I have a Delphi ListView with ViewStyle := vsReport. I'm displaying numeric data and would like to set all the columns to right justiied. I have been able to right justify all the columns except columns[0]. For some reason, columns[0] won't allow the taRightJustify. It only allows taLeftJustify.
Is it possible to set columns[0] to be right justified? If so how do you do this?
TListView does not natively support what you are asking for, due to a Microsoft limitation rather than a VCL limitation:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb774743.aspx
The alignment of the leftmost column is always LVCFMT_LEFT; it cannot be changed.
The only way to align the text of columns[0] is to owner-draw it.
Otherwise, switch to another control, such as Virtual Treeview.
A workaround can be to start adding a column and set the first column with 0 with (to make it invisible). Just remember that all columns are now in subItems.

TcxGrid column is hidden when dragging to group row

I have two seemingly identical TcxGrids bound to two different tables. On one grid, when the column header is dragged and dropped to the group panel, a large X appears above the column being dragged, when it is dropped the column is immediately hidden. On the other grid a big circle with a line through it shows and it cannot be dropped on to the group panel. The Options.Grouping for both columns is false. Why the difference in the two behaviors ? I cannot see a property setting difference but I'm sure there must be one somewhere that causes this behavior. What property is it ?
John
Inspect the properties of the column which won't group in the Object Inspector. Probably, you'll find that its DisableGrouping property is set to True. If it is, set it to False. If that doesn't work, a) I'll take this answer down and b) edit your q to add the contents of your DFM.
There are two places in DX grid that control the ability to group columns. First is at the grid level and it takes precedent over the columns' individual Options.Grouping settings. Second is at the column level. Look at .OptionCustomize.ColumnGrouping. It may be set to False.

cxGrid expand row height to new line with enter

This is a little hard to explain so please bear with me. When I am editing a text field in one of the columns I would like to,when I hit enter, go to new line under the edited text so the grid basically expands.
Options-View-CellAutoHeight set to true expands the cell but editing is terrible.Cant
see a thing where the first line is,where it ends,etc...
Here is the grid:
I can not go after the last letter 'a' with my mouse cursor and hit enter so another line gets added. Which settings regulate this ? I know it can be done since I had a grid once and could do this.
EDIT: This requires no code just applied settings.
Just tested it with DevExpress VCL 13.2 and it can be easily done without coding (if I understood what you want to achieve).
Basically, you need to set following properties:
Assign a Memo to the Properties of your column and make sure its WantReturns property is set to true.
In your TableView set the OptionsView.CellAutoHeight property to true.
Also in your TableView, set the OptionsBehavior.EditAutoHeight to either eahEditor (editor is sized vertically to fit the content) or eahRow (the entire row is sized when editing) as needed.

Column.Index is not reflecting immediately in TDBGrid

I have a TDBGrid and have a Client dataset associated through a TDataSource.
When i try to re-arrange the columns of the grid programtically this works fine when there are one or more columns in the grid.
Lets say, i made all the columns visible to false. So, the grid does not have any columns yet.
Now, when i set the Index of column at 11 to 0.
Columns[iColIndx].Index := iNewColIndex;
// Assume iColIndx = 11 and iNewColIndex = 0
Columns[iNewColIndex].Visible := True;
//Making the column visible
The above assignment of column index is not getting reflected in the Grid. If i try setting it for twice or thrice, then it is getting reflected. Am i missing anything?
I solved it. I have assigned OnDrawDataCell of the grid for drawing the gradients, but I was not calling the DefaultDrawDataCell from there. Moreover, the DefaultDrawing property was turned off.
After setting DefaultDrawing and calling DefaultDrawDataCell from within the DrawDataCell event handler, it is working fine now.

Resources