Jump to content
Xtreme .Net Talk

Xanatos

Members
  • Posts

    5
  • Joined

  • Last visited

Xanatos's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. It's really more of a matter of java vs .NET. Most people fail to realize that Java and .NET are more alike, as far as running their applications on different platforms. Without the JRE, Java apps will not run. Without a CLR, .NET apps will not run. I see no difference between either. Just because there is a JRE for the many different platforms doesn't mean that there won't be a CLR for the others. Java has had more time to develop their JREs for the seperate platforms and I'm sure that the CLRs will begin to be created for the different systems.
  2. Within the loop, perform a 5 second wait in the Exception clause before continuing. Check out this article for regular expressions: http://www.devarticles.com/c/a/VB.Net/Regular-Expressions-in-.NET/
  3. For the first part, you could use regular expressions to check the filename and see if it meets your criteria. If it does, then you can rename it as you need to since you know that the ACTUAL filename matches the regular expression filename. For your second question, I wouldn't have your exception fire off a call to the same function again. Try putting it into a loop. Here's the basics of what I mean: Private Sub CheckLock() Dim i As Integer = 0 Dim myFileStream As Stream Dim fi As FileInfo fi = New FileInfo(strPL1SAPPath & "\ZGPSIN0001_OUTBOUND_.txt") Dim openSuccessful As Boolean = False If fi.Exists() Then Do Until(i = 5 Or openSuccessful) Try 'try to open it to see if it was locked myFileStream = New FileStream(strPL1SAPPath & "\ZGPSIN0001_OUTBOUND_.txt", FileMode.Open, FileAccess.Read) openSuccessful = True 'if an exception occurs the file is locked Catch ex As Exception i = i + 1 'try for 5 times i is global If i = 5 Then MailException("An error occurred when checking if file was locked." & Chr(13) & Chr(13) & ex.ToString()) Application.Exit() End If Finally If Not (myFileStream Is Nothing) Then myFileStream.Close() End Try Loop End If End Sub Try the above code.
  4. Public Shared Sub GridAutoSize(ByVal ds As DataSet, ByVal dg As DataGrid, ByVal dgName As String) dg.DataSource = ds.Tables(0) dg.Expand(-1) dg.NavigateTo(0, dgName) Dim gr As Graphics gr = dg.CreateGraphics Dim intPadding As Integer = 5 Dim sz As SizeF 'sz = gr.MeasureString(New String("M", intPadding), dg.Font) Dim gridStyle As New DataGridTableStyle gridStyle.MappingName = dgName gridStyle.AlternatingBackColor = GridUtility.AlternatingBackColor gridStyle.BackColor = GridUtility.BackColor gridStyle.SelectionBackColor = GridUtility.SelectedBackColor Dim t As New DataGrid If (dg.TableStyles.Contains(dgName)) Then dg.TableStyles.RemoveAt(0) End If If (ds.Tables.Count > 0) Then Dim col As DataColumn For Each col In ds.Tables.Item(dgName).Columns Dim dgCol As New DataGridTextBoxColumn Dim colCount As Integer colCount = ds.Tables.Item(dgName).Columns.Count() sz = gr.MeasureString(col.ColumnName, dg.Font) dgCol.MappingName = col.ColumnName dgCol.HeaderText = col.ColumnName dgCol.Width = sz.Width + 15 dgCol.Alignment = HorizontalAlignment.Left dgCol.TextBox.Enabled = False gridStyle.GridColumnStyles.Add(dgCol) Next If (ds.Tables.Item(dgName).Rows.Count > 0) Then Dim dr As DataRow Dim dtCol As DataColumnCollection dtCol = ds.Tables.Item(dgName).Columns Dim i As Integer i = dg.VisibleRowCount For i = 0 To dg.VisibleRowCount - 2 ' Calculate width on all visible rows (header row counted) For Each col In dtCol ' Loop through each column dr = ds.Tables.Item(dgName).Rows(i) ' Navigate to visible rows ' Measure the "width" of the txt in the first row of each bound DataTable column sz = gr.MeasureString(dr(col.ColumnName).ToString, dg.Font) ' Measure "width" of data value gridStyle.GridColumnStyles(col.ColumnName).Width = _ Math.Max(sz.Width + intPadding, gridStyle.GridColumnStyles(col.ColumnName).Width) Next ' Next DataGrid Column Next i ' Next DataRow dg.TableStyles.Add(gridStyle) End If End If End Sub
  5. I know the question was asked a while back but here's what I found from another forum. The code assumes that the images are stored in an ImageList.: http://www.vbdotnetforums.com/showthread.php?t=2124 using System; using System.Windows.Forms; using System.Drawing; namespace ImageColumnStyleTest { /// <summary> /// Summary description for ImageColumnStyle. /// </summary> public class ImageColumnStyle : DataGridColumnStyle { private Image image = null; public static ImageList imageList = null; public ImageColumnStyle() : base() { } protected override void Abort(int rowNum) { Invalidate(); } protected override void Edit(CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible) { } protected override bool Commit(CurrencyManager dataSource, int rowNum) { return true; } protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, CurrencyManager source, int rowNum) { Paint(g, bounds, source, rowNum, false); } protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, CurrencyManager source, int rowNum, bool alignToRight) { Paint( g, bounds, source, rowNum, Brushes.Red, Brushes.Blue, alignToRight); } protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) { int index = (int)base.GetColumnValueAtRow(source, rowNum); InitImage(index); Rectangle rect = new Rectangle(bounds.Location, imageList.ImageSize); g.FillRectangle(backBrush, bounds); g.DrawImage(image, rect); } protected override int GetPreferredHeight(Graphics g, object value) { return imageList.ImageSize.Height; } protected override int GetMinimumHeight() { return imageList.ImageSize.Height; } protected override Size GetPreferredSize(Graphics g, object value) { return imageList.ImageSize; } private void InitImage(int index) { if(imageList != null && imageList.Images.Count >= index + 1) { image = imageList.Images[index]; } } } }
×
×
  • Create New...