|
godevg wrote: Selection.TypeText Text:="(" & AuthorName(N) & Year(N) & ")"
Looks like you are missing a linefeed somewhere?
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
is it possible to limit picturebox picture size?
i've searched all day in google, they're all limitation in width and height, the size limit i mean is like 500KB or 1MB.
|
|
|
|
|
Pictures can't be limited in file-size by loading them; you can't load half a picture and decide that you had enough, since it would be only half-a-picture.
Load the image, resize it (width and height), reduce colors, save it in a different format; those are ways to reduce the file-size.
Bastard Programmer from Hell
|
|
|
|
|
When I am scrolling datagrid after selecting one row I am getting error as "An unhandled exception of type System.StackOverflowException occurred in System.Windows.Forms.dll" on line :
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText, cellIsVisible)
Whole code is given below :
' Hosts a TextBox control in a cell of a DataGridColumnStyle for editing strings.
'
' Note:
' Adds the ability to change the color of an individual cell. As each row in the column is
' painted an event is fired that allows the setting of the new color.
' Added returning the cell value when it's being painted. Also if the row is selected the
' selection colors will be used.
'-----------------------------------------------------------------------------------------------'
' Additional namespaces.
Imports System.Windows.Forms
Imports System.Drawing
Public Class FormatableCellDataGridTextBoxColumn
' Base class.
Inherits DataGridTextBoxColumn
' Delegates.
Public Delegate Sub PaintingCellEventHandler( _
ByVal sender As Object, _
ByVal e As PaintingCellEventArgs)
Public Delegate Sub EditingCellEventHandler( _
ByVal sender As Object, _
ByVal e As EditingCellEventArgs)
' Events.
Public Event PaintingCell As PaintingCellEventHandler
Public Event EditingCell As EditingCellEventHandler
' Instance variables.
Private _columnNum As Integer
Public Sub New(ByVal columnNum As Integer)
' Initialize instance variables.
_columnNum = columnNum
End Sub
Protected Overloads Overrides Sub Paint( _
ByVal g As System.Drawing.Graphics, _
ByVal bounds As System.Drawing.Rectangle, _
ByVal source As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, _
ByVal backBrush As System.Drawing.Brush, _
ByVal foreBrush As System.Drawing.Brush, _
ByVal alignToRight As Boolean)
' Local variables.
Dim foreColor As Color
Dim backColor As Color
Dim rowIsSelected As Boolean = False
Dim text As String = NullText
Dim value As Object = GetColumnValueAtRow(source, rowNum)
Dim arg As PaintingCellEventArgs
' Determine if the row is selected.
If TypeOf foreBrush Is SolidBrush AndAlso TypeOf backBrush Is SolidBrush Then
foreColor = DirectCast(foreBrush, SolidBrush).Color
backColor = DirectCast(backBrush, SolidBrush).Color
If _
foreColor.Equals(DataGridTableStyle.SelectionForeColor) AndAlso _
backColor.Equals(DataGridTableStyle.SelectionBackColor) Then
rowIsSelected = True
End If
End If
' Retrieve brushes.
If Not IsDBNull(value) Then text = value.ToString()
arg = New PaintingCellEventArgs( _
rowNum, _
_columnNum, _
text, _
backBrush, _
foreBrush)
If Not rowIsSelected Then RaiseEvent PaintingCell(Me, arg)
' Paint the cell.
MyBase.Paint(g, bounds, source, rowNum, arg.BackBrush, arg.ForeBrush, alignToRight)
End Sub
Protected Overloads Overrides Sub Edit( _
ByVal source As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, _
ByVal bounds As System.Drawing.Rectangle, _
ByVal [readOnly] As Boolean, _
ByVal instantText As String, _
ByVal cellIsVisible As Boolean)
' Local variables.
Dim editBoxIsToBeHidden As Boolean = False
Dim e As New EditingCellEventArgs(rowNum, _columnNum, editBoxIsToBeHidden)
' Retrieve edit instructions.
RaiseEvent EditingCell(Me, e)
' Allow the call to progress normally.
MyBase.Edit( _
source, _
rowNum, _
bounds, _
[readOnly], _
instantText, _
cellIsVisible)
' Hide the edit box.
If e.EditBoxIsToBeHidden Then
Me.HideEditBox()
End If
End Sub
End Class
|
|
|
|
|
First, if you're going to post code put it inside PRE tags so it's retains it's formatting and is readable.
Second, there are no definitions for PaintingCellEventArgs and EditingCellEventArgs, so we have no idea how you're getting values from the client code.
We also have no idea what the client code looks like that is filling it these values.
...and I can't quite put my finger on it, but as it stands, this code looks a bit ... funky.
|
|
|
|
|
I'm just stuck here ...
Given:
Dim i As Integer = 1
Debug.Print(i.ToString("000"))
What I can't seem to figure out is the correct format string to be used with .ToString to give me two spaces then the number 1. (which would be right aligned)
|
|
|
|
|
I use string.PadLeft() to right-align some text...
|
|
|
|
|
PadLeft is the winner.
Just what I was looking to do.
Thanks,
david
|
|
|
|
|
Composite formatting using indexed placeholders "{0}" allows for alignment but standard formatting with the ToString method does not.
Example of alignment in a fixed width field
Console.WriteLine("{0, -4}", 99);
Console.WriteLine("{0, 4}", 99);
Debug.Print has an overload for composite formatting so you can do the same trick.
Alan.
|
|
|
|
|
String.Format will do what you want for creating strings.
|
|
|
|
|
Don't think there is one! You'd have to create a string and add leading spaces according to its initial length.
|
|
|
|
|
Good day, i have an application which can upload and preview image files, e-presentations, word duments, excel files and pdf files. On my program i used Web Browser Control and I'm planning to change the component or upgrade the software. Aside from Web Browser Control, what else can I use to preview those file types? Any suggestions and comments will be appreciated.
darylljoecanan™
|
|
|
|
|
Don't post the same question in multiple places. You already posted it in QA.
Once is enough and the regulars around here will see it.
|
|
|
|
|
Dear, The code project admin..
when i make a vb project into an exe file, i have a problem, appear it says file not found : cs2.exe
what should i do to solve the problem?
thank you for the solution...
|
|
|
|
|
Find the file! Seriously, what is the build system trying to do at the point that it cannot find this file? If this is one of the Visual Studio files then you may need to do a re-install.
|
|
|
|
|
so, the error occur because there are corrupted file?
|
|
|
|
|
rizaky2011 wrote: the error occur because there are corrupted file?
No, the error has occurred because a file cannot be found. Check the build logs to see where the file is supposed to be stored and check those directories. If the file is definitely missing then a re-install of VS should fix it.
|
|
|
|
|
|
Solution concept: I am doing a recursive search through directories to find Excel files and then silently open them to find all the macro code, copy the code and then store it.
Problem: When I open some Excel documents, some of these documents have external data connections (ODBC and XML Sharepoint Lists). When the refresh occurs prompts for data source credentials pop-up. Excel tries to refresh the data on this line:
ExcelWb = ExcelApp.Workbooks.Open(FileName, , True, )
before I can get the chance to iterate through the connection collection and disable refresh.
My code snippet for opening the Excel workbook is:
Dim ExcelWb As Microsoft.Office.Interop.Excel.Workbook
Dim ExcelApp As Microsoft.Office.Interop.Excel.Application
ExcelApp = New Microsoft.Office.Interop.Excel.Application
ExcelApp.DisplayAlerts = False
ExcelApp.EnableEvents = False
ExcelWb = ExcelApp.Workbooks.Open(FileName, , True, )
which is fine and everything else in the solution works.
The .ConnectionsDisabled property of the .Workbook object is a read only property, and as I say the refresh occurs in the .Open method before going to the next line of code, not giving me the opportunity to disable conneciton objects in the collection.
I am using the Interop namespace rather than the tools namespace, but I don't think that makes much of a difference regarding object methods and properties.
Is there a better way to manage this to disable the connection refresh?
|
|
|
|
|
Found a solution. Not necessarily the right way, but it works.
adding these two lines before opening the workbook seems to fix the issue.
ExcelApp.AutomationSecurity = 3
ExcelApp.AskToUpdateLinks = True
The first line completely disables all macros, by default security is set to Low.
Second Line, the default is to autmatically update links. By forcing a prompt even when the UI is supressed, the automation component continues and no noisy dialog boxes appear.
|
|
|
|
|
Hi,
I have a DataSet with two tables that have a common field.
Table 1 contains order header data and table 2 order row data. Both tables contain data of multiple orders.
I want to handle each order separately, and my current method is a loop inside a loop and a "manual" check. For example something like this:
For Each rwH as DataRow in ds.Tables("H").Rows
For Each rwR as DataRow in ds.Tables("R").Rows
If rwH.Item("KeyField").ToString = rwR.Item("KeyField").ToString Then
End If
Next
Next
The question is, is there a way to avoid having to loop through the rows, and use this sort of crudish comparison ?
I was thinking maybe creating a foreign key constraint. However, although I know how to create the constraint, I do not know how to use it to my advantage with any loop (assuming it is possible at all) ?
Or can someone suggest an alternative (better) method ?
All input is appreciated.
Cheers,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Why not have a query that joins the two tables and groups by KeyField or something of that nature?
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Please see my answer to Dave's post.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Soooo, you're going to look at the same set of records (inner loop) over and over again, until you match them up with the records in the outer loop?? How many records in the outer loop again?? That seems AWFULLY inefficient.
Why not just create a SQL query that matches everything up for you?
|
|
|
|
|
It is awfully inefficient, hence the question.
In this scenario I need to create orders into an ERP system via a proprietary driver.
That means that I need to declare a new "order" object, and fill in all its properties. Some header data (customer name, and address, and such), and an unknown number of rows (product number, quantity, price, etc.). In addition I need to translate that same information into an email message.
So if I combine both header and row data into a single query, I would have to populate the header data of the order object over and over, for each row, or build in some kind of is-it-already-populated method. Somehow that does not seem very efficient (or elegant) either (I may very well be wrong of course).
For clarity, the header table will generally only contain between 1 and 10 records, the rows table however can contain anywhere between 1 and 150 records per header record. Eliminating the nested loop is therefore my main concern here.
My advice is free, and you may get what you paid for.
modified 6-Jun-12 3:03am.
|
|
|
|
|