Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C1 True DBGrid question

Status
Not open for further replies.

bigfoot

Programmer
May 4, 1999
1,779
US
I know some of you use this control.

I'm testing out C1's grid. I want to take a database and add an unbound column. Simple right?
No. It seems all of their tutorials use the drag and drop version to set up the dataset. Winms. LOL
I want to do it in code which does not work.

Can someone please take a look for me?

Code:
Open the connection...

sSQL = "select a,b,c from Agency"
Dim myDataAdapter As New SqlDataAdapter(sSQL, myConnection)

Dim myDataSet = New DataSet
myDataAdapter.Fill(myDataSet, "agency")

C1TrueDBGrid1.DataSource = myDataSet
C1TrueDBGrid1.DataMember = "agency"

'This all works by itself

Now I read:
The UnboundColumnFetch event is raised when a bound needs to display the value of a cell in an unbound column as specified by the Row and Col arguments. For a bound grid, any column with an empty DataField property and a non-empty Caption property is considered an unbound column.

So I added a column in the visual property editor.

Code:
Private Sub C1TrueDBGrid1_UnboundColumnFetch(ByVal sender As System.Object, ByVal e As C1.Win.C1TrueDBGrid.UnboundColumnFetchEventArgs) Handles C1TrueDBGrid1.UnboundColumnFetch

e.value = "gary"
End Sub

Nothing. In fact the column does not even show up. I think the unbound column conflits with the columns coming off the database, since I did not have to set them up.

Is this right?

Thanks

(So far Infragistics grid is much easer to use and program).
 
why not just add a column to your datatable??

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Because I want to use an unbound column. I need a dozen of those.
 
Sorry...I use this control all the time, but never bothered with unbound columns. I always just add the columns to my datatable.


Sweep
...if it works dont f*** with it
curse.gif
 
I use the unbound columns for icons. That way I can read them in from a folder and display them. :)
 
I use icons in TrueDBGrid all the time too. I simply get an Integer value back from SQL, which I use to point at an index position in an ImageList.


Sweep
...if it works dont f*** with it
curse.gif
 
That's kinda what I am doing except how do you show the icon if not in an unbound column? Do you use the same column that you got the integer number from to display it?
Sounds right.
 
How do you substitute the integer for the icon?
 
Yes..Im using the same column. Ive subclassed the grid for a start and then in my build grid method I use the following to assign a field to an image. In this case a Red/Orange/Green traffic light state

Code:
.zSetImages("pcutstatus", "0", 0)
.zSetImages("pcutstatus", "1", 1)
.zSetImages("pcutstatus", "2", 2)

Then in the Class itself.
Code:
Public Sub zSetImages(ByVal sColumnName As String, ByVal sColumnValue As String, ByVal iImageIndex As Integer)

Dim Item As New C1.Win.C1TrueDBGrid.ValueItem

With Me.grid1.Columns(sColumnName).ValueItems.Values
     Item.Value = sColumnValue
     Item.DisplayValue = Me.oImageList.Images(iImageIndex)
     .Add(Item)
     Me.grid1.Columns(sColumnName).ValueItems.Translate = True
End With

End Sub



Sweep
...if it works dont f*** with it
curse.gif
 
Where do you call the .zSetImages from?
 
Its all very subclassed with methods for choosing which columns to display, widths, formats etc. I always have a custom zbuildGrid method which is called as and when needed as such

Code:
With xGrid
     .zSetDatasource(dt)

     .sColumnsToShow = "pcutstatus,scode,ssize,grade,tocutqty,tocutweight,camber,sawlists"

     .zSetColumnHeaders(",Code,Size,Grade,Qty to Cut,Weight to Cut,Camber,Cut on SawLists")
     .zSetColumnWidths("20,40,150,100,80,100,60,200")
     .zSetColumnAlignments("C,L,L,L,C,R,C,L")

     .zSetImages("pcutstatus", "0", 0)
     .zSetImages("pcutstatus", "1", 1)
     .zSetImages("pcutstatus", "2", 2)
     .zShowColumnFooters(True)

     .zSetColumnFooter("tocutqty", AggregateFunctions.Sum)
     .zSetColumnFooter("tocutweight", AggregateFunctions.Sum)

     .zSetColumnHeaderImage("pcutstatus",Me.xImage.Images(3))

End With



Sweep
...if it works dont f*** with it
curse.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top