We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

GGC col width & selected record event

Hello,

I put image in ggc column header by this snippet:

sub ggc_TableControlDrawCell
Dim s As String = e.Inner.Style.Text
e.Inner.Style.ImageList = ImageList1
e.Inner.Style.Text = vbNullString '" "c
'//Draw the ColumnHeader cell in a Grid.
Dim crect As Rectangle = New Rectangle(e.Inner.Bounds.Location, New Size(e.Inner.Bounds.Size.Width - e.Inner.Style.ImageList.ImageSize.Width, e.Inner.Bounds.Height))
e.Inner.Renderer.Draw(e.Inner.Graphics, e.Inner.Bounds, e.Inner.RowIndex, e.Inner.ColIndex, e.Inner.Style)
'//Draw the image & text in a Grid.
Dim irect As Rectangle = New Rectangle(New Point(e.Inner.Bounds.Right - 5 - e.Inner.Style.ImageList.ImageSize.Width, e.Inner.Bounds.Top - 2), e.Inner.Style.ImageList.ImageSize)
e.Inner.Graphics.DrawString(s, e.Inner.Style.Font.GdipFont, New SolidBrush(e.Inner.Style.TextColor), crect)

e.Inner.Graphics.DrawImage(e.Inner.Style.ImageList.Images(2), irect) '//Draw the image in a Grid di kanan
e.Inner.Style.Text = s
e.Inner.Cancel = True
end sub

1. Problem: The header text was truncated most of times, how to make the column width automatic resize to fit the image and text to avoid truncated text?

2. What is the GGC event name for detecting any record row changed and fired only 1 time?

I used:
ggc_SelectedRecordsChanged
But the first time cell enter, it enumerated through all nested tables thus fired as many as nested tables, and next time it always fired two times?
I wish to get only 1 time event raised, since I need to get particular record calculated to a function if the user click another record row. What is the other way around?

Thanks,
Harry


2 Replies

AD Administrator Syncfusion Team February 21, 2008 12:31 PM UTC


Hi Harry,

1) You can make the column width automatic resize to fit to the image and text by using GridImageCellModel as follows :


Private imageCell As GridImageCellModel = New GridImageCellModel(gridDataBoundGrid1.Model)
'setup how image is fitted to cell
Private imageCell.CellDrawOption = GridImageCellDrawOption.FitProportionally


Please refer the sample in the below link which illustrates the automatic resize of text and image.

http://websamples.syncfusion.com/samples/Tools.Windows/F71912/main.htm”>http://websamples.syncfusion.com/samples/Tools.Windows/F71912/main.htm

2)You can use CurrentRecordContextChange instead of the SelectedRecordsChanged event that detect any record changed as follows.


Private Sub gridGroupingControl1_CurrentRecordContextChange(ByVal sender As Object, ByVal e As CurrentRecordContextChangeEventArgs)
If e.Action = CurrentRecordAction.EndEditComplete Then
Console.WriteLine(e.Record)
End If
End Sub


You can also see the forum that discuss about the selection changed from the below link :


http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=344


Please let me know if this helps you.

Regards,
Asem.






HA Harry February 25, 2008 07:48 AM UTC

Hello Asem,

1. This code didn't work with GridGroupingControl:
Private imageCell As GridImageCellModel = New GridImageCellModel(gridDataBoundGrid1.Model)
'setup how image is fitted to cell

Is this code should be put in Form_Load event?
Private imageCell.CellDrawOption = GridImageCellDrawOption.FitProportionally

2. How to access specified record of particular column (e.g. "Description") by: e.record.... ?

Thanks!
Harry


Loader.
Live Chat Icon For mobile
Up arrow icon