473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Datagridview +imagecolumn

I've got a datagridview that is bound to a table "orders" of my db.
There are 5 column: 4 textcolumn and 1 imagecolumn:
code (textcolumn) search (imagecolumn) description (textcolumn) UM
(textcolumn) Qty (textcolumn) Price (textcolumn)
I'd like to put an image into the search column (imagecolumn) that is
the same for all columns i go create.
Now I can view an icon with a red cross inside.
A part of my vb code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dg1.DataSource = Nothing
agg_righe()
riempi_righe()
ds_righe.Tables(0).Clear()
'etc
End Sub

Dim ds_righe As New DataSet

Private Sub riempi_righe()
Try
Dim cn As New SqlClient.SqlConnection("Data
Source=(local); User ID=sa; Password=sa; Initial Catalog=Ordini;Packet
Size=4096")
cn.Open()
Dim strSQL As String
strSQL = "SELECT * FROM ROrd"
Dim da As New SqlClient.SqlDataAdapter(strSQL, cn)
da.Fill(ds_righe)
dg1.DataSource = ds_righe.Tables(0)
ds_righe.Tables(0).Clear()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub agg_righe()
Dim col1 As New DataGridViewTextBoxColumn
With col1
.DataPropertyName = "codart"
.Name = "codice_riga"
.HeaderText = "Cod.Art"
.Width = 120
.SortMode = DataGridViewColumnSortMode.NotSortable
End With
dg1.Columns.Add(col1)
Dim col2 As New DataGridViewImageColumn
With col2
.Name = "ricart_riga"
.HeaderText = ""
.Width = 20
.SortMode = DataGridViewColumnSortMode.NotSortable
End With
dg1.Columns.Add(col2)
Dim col3 As New DataGridViewTextBoxColumn
With col3
.DataPropertyName = "descr"
.Name = "descrizione_riga"
.HeaderText = "Descrizione"
.Width = 250
.SortMode = DataGridViewColumnSortMode.NotSortable
End With
dg1.Columns.Add(col3)
Dim col4 As New MaskedEditColumn
With col4
.DataPropertyName = "um"
.Name = "um_riga"
.HeaderText = "UM"
.Width = 30
.Mask = "99"
.SortMode = DataGridViewColumnSortMode.NotSortable
End With
dg1.Columns.Add(col4)
Dim col5 As New DataGridViewTextBoxColumn
Dim DataGridViewCellStyle2 As
System.Windows.Forms.DataGridViewCellStyle = New
System.Windows.Forms.DataGridViewCellStyle
DataGridViewCellStyle2.Format = "N2"
DataGridViewCellStyle2.NullValue = "0"
col5.DefaultCellStyle = DataGridViewCellStyle2
With col5
.DataPropertyName = "qty"
.Name = "qta_riga"
.HeaderText = "Q.tà"
.Width = 70
.SortMode = DataGridViewColumnSortMode.NotSortable
End With
dg1.Columns.Add(col5)
End Sub
Thanks a lot.
George

Apr 6 '07 #1
0 1445

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tommy | last post by:
Hi all, I use DataGridView in my form and add image column and 2 textbox column, and I want to change image column's image on runtime. But there is no any example on this function. What can I do ?...
2
by: hazz | last post by:
in a databound scenario I have a database column value that is of type varchar with 3 discrete text values. Binding to this table column with autogenerated columns displays the text values in a...
1
by: Luca Beretta | last post by:
I think this a simple question but i'm breaking my brain without results. I've a datagridview bounded to a datatable, with an imagecolumn that should contain a different bitmap depending from a...
2
by: Marc Solé | last post by:
Hello, I want to insert an image to a specific column of a dataGridWiew. I explain what I'm doing: - I define the ColumnType as a DataGridViewImageColumn. - I select the image (an icon of...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
3
by: obrienkev | last post by:
Hi, I have an ImageColumn in my DataGridView. I have run a query to return 'myCmtPosID' from 'myComments' table. I then want to check if 'myCmtPosID' matches with 'myPosID'. 'myPosID' is a...
3
by: Screaming Eagles 101 | last post by:
Hi, is there an easy way to add a picture(box) to a column in a datagridview ? My first column has a code, ex. 1, 2 or 3 According to these codes I'dd like to add a picture(box) to my second...
0
by: lucoin | last post by:
as add imagecolumn to the datagridview which contains the photo path. the problem I have to click the button twice, then the picture comes. the code as follows. Dim ds As DataSet ...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.