|
Thank you very much Anthony. It worked like a charm. You da man.
Alex.
|
|
|
|
|
I am new to "The Code Project".
I was attracted to this site due to an article; "Advanced DataGrid Formating with ItemDataBound".
The article identified how to format ADO.Net Datagrid rows conditionally.
I need to do the same from a VB.Net Datagrid.
My Application provides the user a datagrid that displays equipment calibration related data. I.E. "Equip. Serial #", "Due dates" ETC...
I want to conditionally change the color of rows (records) who's "Due date" columns are greater than the current date; DueDate > Today()
Thus, visually identifing records which need to be prioritized.
Can anyone direct me to an article, or perhaps point me in the right direction?
Regards:
DDscales
DDscales
|
|
|
|
|
Hi DDscales.
Try Using
[c#]
this.dataGridView1.Rows[0].DefaultCellStyle
Or if you are using the a DataSet use DataBindings to set the properties with the correct datamember.
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
Perhaps I am just to green.
I assume "this." refers to my DataGrid "DataGrid1" ?
Also, I notice in your reply [c#], I am running VB 2003. Or does that matter?
Anyway...I think my problem is I do not know how to set the dataGridView properties. Do I have to create a class Library?
I realize this could get rather complicated. Could you refer me to an article or virtual lab that might help me to get the answers?
Regards:
DDscales
|
|
|
|
|
I have a function that needs to be called anytime the form is re-sized, minimized or maximized. In VB6, I could just set the AutoRefresh and call the function in the resize routine and everything worked fine. It doesn't seem to work that way in VB.NET. Any ideas?
Thanks,
Tim Alvord
|
|
|
|
|
There's an event for the form resizing, and another, I believe, for if the state is changed.
|
|
|
|
|
A user, Craig Gemmill, on another forum solved it this way. It's pretty slick:
Private Sub frmJournal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetStyle(ControlStyles.UserPaint, True)
SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.ResizeRedraw, True)
Me.UpdateStyles()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Using gradientBrush As New Drawing2D.LinearGradientBrush(Me.ClientRectangle, Color.Black, Color.Blue, Drawing2D.LinearGradientMode.Vertical)
e.Graphics.FillRectangle(gradientBrush, Me.ClientRectangle)
End Using
End Sub
Tim Alvord
|
|
|
|
|
I'm not sure if this is possible....but I was wondering if it is it possible to set properties (like set different font styles/font sizes) to items within a listbox or combobox. Any help woud be greatly appreciated, thank you in advance!
|
|
|
|
|
No, you need to create an owner drawn listbox to do this ( or look for one on the site )
|
|
|
|
|
Thank you very much, I'll try that.
|
|
|
|
|
I need to know how to make sure a row is numeric when written to the database. Here is some sample code:
FormatCost = Format(CSng(row("dealernetpricedollars")), "c").ToString()
Thanks!
jds1207
|
|
|
|
|
|
Ok. What do I use if the row is not numeric?
|
|
|
|
|
You asked how to know if the value is numeric... since the question was posed in a VB forum, the answer given is the function to test a value in VB.
How the application handles this is another question entirely and beyond the scope of the first question.
|
|
|
|
|
FormatCost = Format(CSng(row("dealernetpricedollars")), "c").ToString()
If isNumeric(FormatCost) = True Then
' Some Code to handle True Condition
Else
' Some code to handle False Condition
End If
DDscales
|
|
|
|
|
I want to take control of installed printers on my computer (network) and from any computer on the network, send data directly for printing.
Could anyone help with some concepts and example code?
omo code
|
|
|
|
|
First, the disclaimer: I have ZERO experience with VB. However, I have been tasked with writing some code for some intensive calculations using VB in Excel. I have discovered that to write data from an array to the Excel worksheet, you can use the following:
Worksheets("Sheet2").Range("A2").Resize(1, UpperLimit).Value = ConvDataEuro
Where UpperLimit is the size of the row and ConvDataEuro is the array holding my data. However, I need to write in excess of 400 array elements and the row limit on Excel is 256. Thus, I want to write the data in columns rather than rows. Unfortunately, this is apparently not easy to do as I have spent the last hour trying to do this with zero success.
So, my question is: how do I take array data and write it to a column in Excel instead of a row? This should be simple, but under VB in Excel it is not intuitive.
TIA.
|
|
|
|
|
1. This is not truly a VB question; it is an Excel question. All languages will be constrained by the object model.
2. Played with the VBA briefly: reverse your resize parameters (UpperLimit, 1)... that appears to work.
YWIA.
Tim
|
|
|
|
|
Hi Tim,
Thanks for the help. I tried switching the limits and what it does is that it prints out an entire column length of the first entry of the array. I managed to get it to work using an alternate method (I am sure, however that there is a better way) whereby I loop through the array and print out each element of the array while incrementing the spreadsheet cell. Like I said, I am sure there is a better/more efficient way of doing this.
Thanks for the answer though - when I have some free time I'll try again.
Also, where else was I to post the question, the Lounge perhaps?
|
|
|
|
|
I have no problem with the question being posed here... and posting it in the Lounge or Soapbox would have resulted in a flaming...
I don't like to use Excel, but, I am required to do so.
I have been bit a number of times by the way it handles Ranges, so, I just don't use them and opt instead for the method you used - loop and fill.
If you have other Excel/VBA questions, ask away... I will answer what I can.
Tim
|
|
|
|
|
I am a VB.net student and have had a relatively easy go of it til now. For some reason the concept of threading has been a problem for me. Our assignment is to make a ball bounce around the screen (changing directions when it hits a wall). It must us a class (ball). and I understand the basic code of making the ball change directions, but have no idea on how to incorporate this using threads. Any pointers or starters would be great.
|
|
|
|
|
Hi mydrive22.
Every application when start has a thread (Primary Thread [PT]).
The Thread is a subprocess, this run at same time that PT.
For example: When you walk and talk, if this process was a only process you need wait for walk process finish and start the talk process. but if you start 1 process for walk and 1 process for talk, the PT proceess is free for do anything.
It's the same with forms.
If you use one proceess for retrieve data, you can use the PT for do anything on the form.
You need study "System.Threading", "Control.BeginInvoke", "Control.EndInvoke", "System.MulticastDelegate"
I hope that this solve your problem
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
Hi,
I have a form which stores regular values(INTO a USER Table) inputed on the same form, in the following way:
objUser.strUsername = System.Convert.ToString(Me.txtUsername.Text)<br />
.<br />
.<br />
.<br />
.<br />
etc..
The problem is, I am trying to store a value INTO the USER Table, from ANOTHER form. I can't do:
objTitle.strTitleName = System.Convert.ToString(frmTitle.txtUsername.Text)
What do I do ?
The thing is the Title being inputed is a checkbox format anyway, NOT a TextBox..
Thanks for the help.
|
|
|
|
|
1) system.convert.tostring is not necessary. the property 'text' is already a string. not need to convert a string into a string.
2) you either need to make the control accessible publically or you can create a readonly property that returns the control's text property.
|
|
|
|
|
Hey guys!
I have drawn a Heart, now I want to know how do we fill it with a color once drawn ¿
The reason I'm asking this, is because adding a GraphicsPath and Filling that path, didn't seem to work. I even declared a new Points array, and tried FillPolygon, but that didn't work either.
This is what I've done with the Graphicspath
Private startPoint As System.Drawing.Point
Private endPoint As System.Drawing.Point
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
startPoint.X = e.X
startPoint.Y = e.Y
End Sub
Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
endPoint.X = e.X
endPoint.Y = e.Y
Panel1.Invalidate()
End Sub
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim hPath As New System.Drawing.Drawing2D.GraphicsPath
Dim width As Integer = Math.Max(endPoint.X, startPoint.X) - Math.Min(endPoint.X, startPoint.X)
Dim height As Integer = Math.Max(endPoint.Y, startPoint.Y) - Math.Min(endPoint.Y, startPoint.Y)
Dim avg As Integer = CInt((width + height) / 2)
If avg > 0 Then
Dim topLeftCorner As Point = startPoint
If endPoint.X < startPoint.X Then
topLeftCorner.X = endPoint.X
End If
If endPoint.Y < startPoint.Y Then
topLeftCorner.Y = endPoint.Y
End If
Dim radius As Integer = CInt(avg / 2)
Dim topLeftSquare As New Rectangle(topLeftCorner.X, topLeftCorner.Y, radius, radius)
Dim topRightSquare As New Rectangle(topLeftCorner.X + radius, topLeftCorner.Y, radius, radius)
e.Graphics.DrawArc(Pens.Black, topLeftSquare, 180.0F, 180.0F)
hPath.AddArc(topLeftSquare, 180.0F, 180.0F)
e.Graphics.DrawArc(Pens.Black, topRightSquare, 180.0F, 180.0F)
hPath.AddArc(topRightSquare, 180.0F, 180.0F)
e.Graphics.DrawLine(Pens.Black, topLeftCorner.X, (topLeftCorner.Y + radius) - CInt((radius / 2)), topLeftCorner.X + radius, topLeftCorner.Y + avg)
hPath.AddLine(topLeftCorner.X, (topLeftCorner.Y + radius) - CInt((radius / 2)), topLeftCorner.X + radius, topLeftCorner.Y + avg)
e.Graphics.DrawLine(Pens.Black, topLeftCorner.X + avg, (topLeftCorner.Y + radius) - CInt((radius / 2)), topLeftCorner.X + radius, topLeftCorner.Y + avg)
hPath.AddLine(topLeftCorner.X + avg, (topLeftCorner.Y + radius) - CInt((radius / 2)), topLeftCorner.X + radius, topLeftCorner.Y + avg)
e.Graphics.FillPath(Brushes.Black, hPath)
End If
End Sub
But it only fills the part with the 2 arcs, and not the lines - so only the top half of the heart is filled.
Any ideas on how I can fill the entire Heart shape while drawing ¿
|
|
|
|
|