View Full Version : سوال: tranceprant کردم بکگراند grid و textbox
systam
پنج شنبه 03 مرداد 1392, 18:18 عصر
سلام
من در برنامه از عکس برای پس زمینه استفاده میکنم اون رنگ بک گرید ویو رنگ خاکستری تیره منو ازار میده
میام توی backcolor رو tranceprant رو انتخاب کنم کنم خطا میگره ؟
اصلا مشه همچنین کاری رو کرد ؟
ممنون میشم راهنمایی کنید
یا علی
systam
جمعه 04 مرداد 1392, 12:43 عصر
سلام به همگی دوستان
برای تکس باکس رو پیدا کردم یک فایل dll پیدا کردم که کاملا backgrand رو transparent میکنه
دمش گرم اقای Bob Bradley در سایت http://www.codeproject.com
این صفحه منبع (http://www.codeproject.com/Articles/4390/AlphaBlendTextBox-A-transparent-translucent-textbo)
کد برنامه به صورت C# بود نتونستم تبدیل کنم کدش شو میزام دوستان تبدیلش کنند به VB
ولی مشخصه فقط باید کامپوننت رو به برنامه اضافه کنی و AlphaBlendTextBox1.BackAlpha = 0 بدی درسته
فایل dll رو ضمیمه کردم
یه چیز دیگه border رو در حالت none قرار دهید
یا علی
systam
شنبه 05 مرداد 1392, 18:00 عصر
سلام
چطوری این کد رو در برنامه استفاده کنم
Imports System.ComponentModel
Public Class TransparentDGV
Inherits DataGridView
Private _DGVHasTransparentBackground As Boolean
<Category("Transparency"), _
Description("Select whether the control has a Transparent Background.")> Public Property DGVHasTransparentBackground As Boolean
Get
Return _DGVHasTransparentBackground
End Get
Set(value As Boolean)
_DGVHasTransparentBackground = value
If _DGVHasTransparentBackground Then
SetTransparentProperties(True)
Else
SetTransparentProperties(False)
End If
End Set
End Property
Public Sub New()
DGVHasTransparentBackground = True
End Sub
Private Sub SetTransparentProperties(ByRef SetAsTransparent As Boolean)
If SetAsTransparent Then
MyBase.DoubleBuffered = True
MyBase.EnableHeadersVisualStyles = False
MyBase.ColumnHeadersDefaultCellStyle.BackColor = Color.Transparent
MyBase.RowHeadersDefaultCellStyle.BackColor = Color.Transparent
SetCellStyle(Color.Transparent)
Else
MyBase.DoubleBuffered = False
MyBase.EnableHeadersVisualStyles = True
MyBase.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.Control
MyBase.RowHeadersDefaultCellStyle.BackColor = SystemColors.Control
SetCellStyle(Color.White)
End If
End Sub
Protected Overrides Sub PaintBackground(graphics As System.Drawing.Graphics, clipBounds As System.Drawing.Rectangle, gridBounds As System.Drawing.Rectangle)
MyBase.PaintBackground(graphics, clipBounds, gridBounds)
If _DGVHasTransparentBackground Then
If Not IsNothing(MyBase.Parent.BackgroundImage) Then
Dim rectSource As New Rectangle(MyBase.Location, MyBase.Size)
Dim rectDest As New Rectangle(0, 0, rectSource.Width, rectSource.Height)
Dim b As New Bitmap(Parent.ClientRectangle.Width, Parent.ClientRectangle.Height)
graphics.FromImage(b).DrawImage(MyBase.Parent.Back groundImage, Parent.ClientRectangle)
graphics.DrawImage(b, rectDest, rectSource, GraphicsUnit.Pixel)
Else
Dim myBrush As New SolidBrush(MyBase.Parent.BackColor)
Dim rectDest As New Region(New Rectangle(0, 0, MyBase.Width, MyBase.Height))
graphics.FillRegion(myBrush, rectDest)
End If
End If
End Sub
Protected Overrides Sub OnColumnAdded(e As System.Windows.Forms.DataGridViewColumnEventArgs)
MyBase.OnColumnAdded(e)
If _DGVHasTransparentBackground Then
SetCellStyle(Color.Transparent)
End If
End Sub
Private Sub SetCellStyle(ByVal cellColour As Color)
For Each col As DataGridViewColumn In MyBase.Columns
col.DefaultCellStyle.BackColor = cellColour
col.DefaultCellStyle.SelectionBackColor = cellColour
Next
End Sub
End Class
اینم سایت منبع
(http://www.vbforums.com/showthread.php?712439-how-to-create-a-datagridview-with-transparent-background)
systam
یک شنبه 06 مرداد 1392, 11:38 صبح
سلام این کد هم هست که تبدیلش کردم نمیدونم چطوری باید استفاده کنم
Protected Sub PaintBackground(ByVal graphics__1 As Graphics, ByVal clipBounds As Rectangle, ByVal gridBounds As Rectangle)
MyBase.PaintBackground(graphics__1, clipBounds, gridBounds)
Dim rectSource As New Rectangle(Me.Location.X, Me.Location.Y, Me.Width, Me.Height)
Dim rectDest As New Rectangle(0, 0, rectSource.Width, rectSource.Height)
Dim b As New Bitmap(Parent.ClientRectangle.Width, Parent.ClientRectangle.Height)
Graphics.FromImage(b).DrawImage(Me.Parent.Backgrou ndImage, Parent.ClientRectangle)
graphics__1.DrawImage(b, rectDest, rectSource, GraphicsUnit.Pixel)
SetCellsTransparent()
End Sub
Public Sub SetCellsTransparent()
Me.EnableHeadersVisualStyles = False
Me.ColumnHeadersDefaultCellStyle.BackColor = Color.Transparent
Me.RowHeadersDefaultCellStyle.BackColor = Color.Transparent
For Each col As DataGridViewColumn In Me.Columns
col.DefaultCellStyle.BackColor = Color.Transparent
col.DefaultCellStyle.SelectionBackColor = Color.Transparent
Next
End Sub
سایت منبش (http://stackoverflow.com/questions/1330220/set-datagrid-view-beckground-to-transparent/2462381#2462381)
systam
یک شنبه 06 مرداد 1392, 14:19 عصر
سلام
یکی نیست کمک بکنه به خدا ثواب داره ها
mports System.ComponentModel
Public Class Form1
Public Class usrDataGridView
Inherits Windows.Forms.DataGridView
Private m_Image As Drawing.Image
Public Sub New()
Me.m_Image = Drawing.Image.FromFile("c:\sisnetBG.jpg")
End Sub
Protected Overrides Sub PaintBackground(ByVal graphics As System.Drawing.Graphics, ByVal clipBounds As System.Drawing.Rectangle, ByVal gridBounds As System.Drawing.Rectangle)
MyBase.PaintBackground(graphics, clipBounds, gridBounds)
graphics.DrawImage(Me.m_Image, gridBounds)
End Sub
Public Property BackImage() As Drawing.Image
Get
Return Me.m_Image
End Get
Set(ByVal value As Drawing.Image)
Me.m_Image = value
End Set
End Property
End Class
منبع (http://www.codeproject.com/Articles/17648/Set-Image-as-Background-for-DataGridView)
systam
دوشنبه 07 مرداد 1392, 20:15 عصر
نمیدونم 126 نفر پست رو نگاه کردند انگار نه انگار !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!! :عصبانی::ناراحت::عصبانی++::گر ه::متعجب:
درستش کردم با کمک جناب khokhan :بوس: که تونستیم عکس رو رو زمینه گرید ویو کنیم
ولی دنبالش هستم که بشه یه بک بی رنگ tranceprant داشته باشیم
برنامه هم به زبون #C هم به زبون VB ضمیمه شد .
یا علی
systam
سه شنبه 08 مرداد 1392, 21:37 عصر
سلام
دوستان اساتید اون برنامه گرید رو میخوان به این شکل در میارم کسی هست کمک کنه
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.