Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2006

Tip: Looking for answers? Try searching our database.

adding images to grid columns? .net 1.1

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
HockeyFan - 10 Aug 2006 15:45 GMT
I have a windows forms .net 1.1 question:
I tried adding an image (a picturebox) to a column in my grid, but haven't
been able to do it adequately.  The pictures are there, but they don't seem
to be visible until I click on a cell and then the picture is visible.  Not
sure what's going on.
Can you tell from the following code, or is there a better way:

   Sub DoAssessmentGrid()
       If bus.AssessmentList(ActionRequested.CaseNumber) Then
           Dim ts As DataGridTableStyle
           ts = dgAssessments.TableStyles(0)
           ts.MappingName = "ClientAssessments"

           Dim booleanColumn As DataGridBoolColumn
           booleanColumn = ts.GridColumnStyles.Item("CompleteBool")
           booleanColumn.TrueValue = True
           booleanColumn.FalseValue = False
           booleanColumn.NullValue = Convert.DBNull

           Try
               Dim executing_assembly As System.Reflection.Assembly =
Me.GetType.Assembly.GetEntryAssembly()
               Dim my_namespace As String =
executing_assembly.GetName().Name.ToString()
               If Not ts.GridColumnStyles.Item("Action") Is Nothing Then
                   ActionColumn = CType(ts.GridColumnStyles.Item("Action"),
DataGridTextBoxColumn)
                   ActionColumn.Alignment = HorizontalAlignment.Center
                   imgEdit = New PictureBox
                   imgExport = New PictureBox
                   Dim curDir As String = Environment.CurrentDirectory()
                   imgEdit.Image =
Image.FromFile("D:\OKDHS\AGING\ELDERS\ELDERSRemote\images\Edit.gif")
                   imgEdit.Cursor = Cursors.Arrow
                   imgEdit.SendToBack()
                   imgExport.Image =
Image.FromFile("D:\OKDHS\AGING\ELDERS\ELDERSRemote\images\btnExport.gif")
                   imgExport.Cursor = Cursors.Arrow
                   imgExport.SendToBack()
                   ActionColumn.TextBox.Controls.Add(imgEdit)
                   imgEdit.BringToFront()
                   'ActionColumn.Width = 65
                   'ActionColumn.TextBox.Controls.Add(imgExport)
               End If

           Catch ex As System.IO.FileNotFoundException
               SystemMessage.Tell("Couldn't find one of the image files for
the grid")
           Catch ex As Exception
           End Try

           dgAssessments.DataSource = bus.ObjectDataSet
           dgAssessments.DataMember = ts.MappingName
       End If
   End Sub
Keith - 10 Aug 2006 15:51 GMT
I'm not going to try and digest your code at the moment, but here's a link I
constantly use when I'm dealing with unique datagrid content in 1.1:

http://www.codeproject.com/dotnet/DataGridEdtAlmostAnythin.asp?df=100&forumid=15
7727&exp=0&select=1168287


> I have a windows forms .net 1.1 question:
> I tried adding an image (a picturebox) to a column in my grid, but haven't
[quoted text clipped - 51 lines]
>         End If
>     End Sub
Claes Bergefall - 10 Aug 2006 16:27 GMT
You are adding your image as a a control (PictureBox) to the textbox
contained in a DataGridTextBoxColumn. That textbox, and hence your
picturebox, is only visible when the cell is active. When the cell is not
active the content is drawn by the overriden Paint method in
DataGridTextBoxColumn.

You need to create you own class derived from DataGridColumnStyle and
override it's Paint method. Item 5.24 in the FAQ found here might help:
http://www.syncfusion.com/faq/windowsforms/Default.aspx

  /claes

>I have a windows forms .net 1.1 question:
> I tried adding an image (a picturebox) to a column in my grid, but haven't
[quoted text clipped - 55 lines]
>        End If
>    End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.