|
Hi
i have a datatable and i want to print it.
what is the best way for it?
(maybe by showing datatable in gridview and then print the gridview;how can i print gridview?)
please somebody help me.
|
|
|
|
|
|
the columns of this datatable isn't clear because this datatable is reply of a select command from database and user can modify number of datatable columns .
you know that i can't change the columns of crystal report .
if you know another way please help me.
|
|
|
|
|
|
I am adding new object in array..and each object I add also to listview. Now i would like to read object that is selected on listview. How I know which object is now selected?
|
|
|
|
|
all selected object are placed in ListView.SelectedItems. It is used in a same way as ListView.Items
|
|
|
|
|
object[] arr = new object[100];
foreach(ListViewItem item in listView1.SelectedItems) {
object selObj = arr[item.Index];
}
|
|
|
|
|
I use
List < blabla > array ... is use of this same as of normal array?
|
|
|
|
|
Yes
example:
List<String> str = new List<String>();
str.Add("Hello");
str.Add("World");
MessageBox.Show(str[0] + " " + str[1]);
|
|
|
|
|
a generic list (e.g. List<int> ) is like a stretchable array, it will grow and shrink as you add/remove items. And you can access its elements using an index, and you can iterate its elements with foreach .
it is all in the documentation!
BTW: if all your objects are in a ListView, then listView.Items is holding them all; so you can index and iterate that directly. (Not a good idea if you need a layered approach, where the ListView is just part of the view, not of the business logic).
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Yes, you can use a generic list exactly like an array in your C# program. The compiler handles the translation chores for you
|
|
|
|
|
Hello @ all
I have a problem with my generated PNG - Images.
It's a bit strange for me but may be someone now what i can do to solve this problem.
My windows service create on the fly PNG - Images and store them as binary in a database.
The stored images are displayed later with a crystal report in a windows app.
That works very fine since years and also with different pc's (most XP-OS), but there is a problem with a new PC (XP-OS) since a few days.
All images are displayed shrunken in the reports and it's not the whole report.... only the images. Text- and Report still proportional.
Could it be that something is missing at the new machine ?
Any ideas how this could be ?
Thanks a lot!
Bitmap couponImg = null;
Font font = null;
Graphics graphic = null;
try
{
couponImg = new Bitmap(coupon.Width, coupon.Height, PixelFormat.Format24bppRgb);
using (graphic = Graphics.FromImage(couponImg))
{
graphic.Clear(coupon.BackgroundColor);
graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
graphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
graphic.TextContrast = 0;
graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
if (coupon.couponCellCollection != null && coupon.couponCellCollection.Count > 0)
{
for (int idx = 0; idx < coupon.couponCellCollection.Count; idx++)
{
font = new Font(coupon.font, (float)coupon.couponCellCollection[idx].fFontSize, FontStyle.Bold, GraphicsUnit.Millimeter);
graphic.DrawString(coupon.couponCellCollection[idx].sCellValue, font, Brushes.Black, new PointF(coupon.couponCellCollection[idx].iPosX, coupon.couponCellCollection[idx].iPosY));
font = null;
}
}
graphic.DrawImage(couponImg, new Rectangle(0, 0, coupon.Width, coupon.height), 0, 0, coupon.Width, coupon.height, GraphicsUnit.Pixel);
graphic.Flush();
}
}
}
catch (Exception)
{
couponImg = null;
}
finally
{
if (graphic != null)
{
graphic = null;
}
}
|
|
|
|
|
Hi
Got stuck here. Word document gets saved in the correct directory with the correct name but the typed text doesn't persist. Please help. (*I have tested that the text is actually typed in the active document).
private void SaveDoc()
{
Word.Application wdApp;
Word.Document wdDoc;
wdApp = new Word.Application();
wdDoc = wdApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
//type some text
wdApp.Selection.TypeText("Some Heading"));
//set rtf doc paragraph 1 style to normal
object wdParaStyleName = "Heading 1"
wdDoc.Paragraphs[1].set_Style(ref wdParaStyleName);
//save rtf doc
wdApp.ChangeFileOpenDirectory("C:\\test\\");
object wdFileName = "TestDoc.rtf"
object saveFmt = Word.WdSaveFormat.wdFormatRTF;
wdApp.ActiveDocument.SaveAs(ref wdFileName, ref saveFmt, ref falseO, ref missing, ref falseO, ref missing, ref trueO, ref falseO, ref falseO, ref trueO, ref falseO, ref missing, ref falseO, ref falseO, ref missing, ref falseO);
//Quit Word
object saveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
wdApp.Quit(ref saveChanges, ref missing, ref missing);
}
Using doc.save() prompts the save dialog which defeats the purpose of automation.
Thanks
GJ
|
|
|
|
|
mailtogj wrote: object saveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
Documentation: This example includes the wdDoNotSaveChanges argument of the Close method to close without saving changes or prompting the user.
Try using the SaveAs() method.
|
|
|
|
|
object saveChanges = Word.WdSaveOptions.wdDoNotSaveChanges; This saves without the inserted text.
SaveAs() also doesn't work for inserting text. Could i possibly catch the save as event for the word application.
|
|
|
|
|
Hi all,
I am trying to catch the delete event from an Outlook appointment item. I can
get it working using the "Item.BeforeDelete" event but if the appointment is
a recurrence and you delete one occurence from the recurrence the
event is'nt triggered. Does any one know a way around this ?
Many thanks in advance
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi
I've got a web service running on a BackgroundWorker which updates the weather in a specified time limit. I've also got a combobox listing a whole bunch of cities. Now the thing is, in the Do_work event of the backgroundworker I update the weather and let the thread sleep for a couple of minutes, and if the user selects a new city, the user has to wait the specified amount of time before it updates. How can I get the weather to update say every 10 minutes, but as soon as a new city is selected, don't wait 10 minutes, and instead update the weather as soon as a new city is selected.
Is there a way to restart the BackgroundWorker perhaps?
|
|
|
|
|
You might want to consider using a ManualResetEvent[^]. In the background thread use the WaitOne method. When the user selects the city, trigger the event and the background thread should continue its processing of the new weather information, otherwise the timeout period will occur and it will refresh as expected.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
A better solution is a combination of a timer and a backgroundWorker.
Add a Timer with the interval set to 10 minutes In the timer Tick event call a new Method, say UpdateWeather . In your new UpdateWeather method test the backgroundWorker IsBusy property and if it is not busy call RunAsync .
The code to change city can then call the same UpdateWeather method.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Understanding that a Timer actually creates a background thread, how is this a "better" solution?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
There is an alternative:
- do not use a BGW
- use a System.Threading.Timer with due time equal to 0, and an infinite period (that makes it a one-shot timer).
- in the timer callback method:
* get the weather info;
* use the InvokeRequired/Invoke pattern[^] to update the GUI;
* set the timer due time to 10 minutes using the Change() method.
- when the user chooses another city, set the timer due time to 0 so it ticks right away.
The advantage is there will be 10 minutes in between weather operations, so they cannot possibly overlap; and you don't need any synchronization. The disadvantage is you need the Invoke stuff for the GUI.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
modified on Monday, November 16, 2009 2:11 PM
|
|
|
|
|
hi is there a way of changing one of the properties of a nullable rectangle.
for example.
private Rectangle? m_RectangleShape;
m_RectangleShape.Value.X = value;
The above is along the lines of what i am looking for, a way to change the x value
Current attempt:
public int X
{
get
{
return m_LocationX;
}
set
{
ShapeRect = new Rectangle(value, m_LocationY, m_SizeX, m_SizeY);
}
}
|
|
|
|
|
Before you can set properties on a nullable rectangle you have to initialise it. It is also best practice to test the HasValue property before setting properties of the value, though not needed at this point.
Rectangle? m_RectangleShape = new Rectangle?();
m_RectangleShape.Value.X = ValueType;
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|