|
hi
i want to extend the standard DataGridView in vs 2005 mySelf, and i want to add footer to DataGridView,this is my code to override paint method :
public partial class ExGridView : DataGridView<br />
{<br />
private int _footerHeight;<br />
public ExGridView()<br />
{<br />
InitializeComponent();<br />
_footerHeight = 20;<br />
}<br />
<br />
public int FooterHeight<br />
{<br />
get<br />
{<br />
return _footerHeight;<br />
}<br />
set<br />
{<br />
if (_footerHeight != value)<br />
{<br />
_footerHeight = value;<br />
Invalidate();<br />
}<br />
}<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
base.OnPaint(e);<br />
Rectangle rOrginal = this.ClientRectangle;<br />
Rectangle rFooter = new Rectangle(0, this.Height, this.Width, _footerHeight);<br />
e.ClipRectangle.Offset(0, _footerHeight);<br />
e.Graphics.DrawRectangle(Pens.Black, rFooter);<br />
e.Graphics.DrawString("Test", this.Font, Brushes.Black, new PointF((float)rFooter.X + 10, (float)rFooter.Y + 5)); <br />
}<br />
} but when compile my app and add myControl (ExGridView) to my form, nothing occured, where does problem and how to solve it ?
|
|
|
|
|
Hi,
seems rFooter is outside the ClientRectangle, so it gets clipped completely.
remedy: give top part of ClientRectangle to base.OnPaint, keep bottom part for your
owner-drawn footer.
|
|
|
|
|
thanks Luc Pattyn
can u say me how to solve my problem and extending clip of DataGridView to contain rFooter Rectangle by code? (because i'm beginner)
thanks
|
|
|
|
|
You can not extend the ClientSize of the DGV.
As I said before, you must split the available ClientSize in two parts;
one part for the DGV and one for your footer.
So that means you must create a new PaintEventArgs with a reduced clip rectangle, and
pass that to base.OnPaint().
|
|
|
|
|
I am working on a project, which uses the Interop.Excel type from the namespace Microsoft.Office
But I get the following error.
Error The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?) I have installed Microsoft office 2003 on my machine. I've got this project copied from another machine to my laptop, but it works fine there. What could be the problem?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
This may be a silly question but have you checked that your references are correct in the VS project on your laptop?
Are the files you are referencing against on the laptop?
That would be my first port of call.
Stu Richardson
|
|
|
|
|
You have to download and install PIAs (Primary Interop Assemblies) for your version of MS Office from Microsoft's site.
|
|
|
|
|
Thank you. That helped me. Sorry for the delayed reply.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I am doing a project that use UPC A barcode. I found the code to convert number to UPC A barcode and it works well. But i am having an error converting UPC A barcode to number.
Is there any to help me. I would be very grateful to You.
Thank you!!
deepak
|
|
|
|
|
hi,
there are a lot of articles related to barcodes in CP.
regards
|
|
|
|
|
i have a string that i wish to store as contents of a textfile.
i would be providing the user with the savedailog option.
can any1 plz guide me as to how can should i develop the code such that whatevr filename the user specifies in the savedialog box,the string data gets transferred to the file in .txt format.
thanks
|
|
|
|
|
StreamWriter class will help you
|
|
|
|
|
string content = "Whatever... :)";<br />
SaveFileDialog fileDialog = new SaveFileDialog();<br />
if (fileDialog.ShowDialog() == DialogResult.OK)<br />
{<br />
TextWriter writer = new StreamWriter(fileDialog.FileName);<br />
writer.Write(content);<br />
writer.Close();<br />
}
|
|
|
|
|
hey thanks manav....
but i have got stuck again.
saveFileDialog1.Filter = "Text File|*.txt|";
this code is giving error for me.how should i cahnge it to save it in a text format.(*.txt)
|
|
|
|
|
saveFileDialog1.Filter = "Text File|*.txt";
|
|
|
|
|
Hello Luc,
Your link to "Forum Guidelines" doesn't work any more!
All the best,
Martin
|
|
|
|
|
Thanks Martin, I think I fixed it now.
|
|
|
|
|
Hello
fileDialog.Filter="*Text File (*.txt)|*.txt";
All the best,
Martin
|
|
|
|
|
Remove | from filter...
Here is the new code
string content = "Whatever... :)";<br />
SaveFileDialog fileDialog = new SaveFileDialog();<br />
fileDialog.Filter = "Text File|*.txt";<br />
<br />
if (fileDialog.ShowDialog() == DialogResult.OK)<br />
{<br />
TextWriter writer = new StreamWriter(fileDialog.FileName);<br />
writer.Write(content);<br />
writer.Close();<br />
}
|
|
|
|
|
Hello,
I found out that my ApplicationContext instance holds a reference of my Splash window (Windows.Forms.Form), so that GC can not free the memory. (MemProfiler[^]told me)
It's not a real problem for my program, but I'm curious why.
My program is working like his:
1) At startup my splash form is instanciated.
2) An ApplicationContext instance is created, with my splash instance as parameter:
AppContext = new ApplicationContext(_splash);
Application.Run(AppContext);
3) Startup continious (instanciates classes like mainwindow and so on) and feeds splash with information to show.
4) Startup finished
5) Now my mainwindow is linked to the ApplicationContext and replaces the splash form.
AppContext.MainForm = _mainwindow;
_mainwindow.Show();
6) Splash is closed and local references which are linked to the splash class got disposed.
_splash.Close();
_splash = null;
.
.
It looks to me that in "5)" I'm doing something unsufficiant, so that AppContext still holds the ref to the splash.
I'm open for all suggestions.
Thanks for your time.
All the best,
MArtin
-- modified at 5:38 Wednesday 13th June, 2007
The ApplicationContext holds the reference to the Splash form over the Application.ThreadContext.RunMessageLoopInner method, where the instance is passed as an argument.
|
|
|
|
|
Hi Martin,
I have no experience wirth ApplicationContext; I once did a splash screen without it.
But I just read an article[^] on it, it may interest you.
Now I discovered same article here ![^]
Regards,
|
|
|
|
|
Hello Luc,
Thanks for the links.
I will go threw them and let you know if it helped.
All the best,
Martin
|
|
|
|
|
Hello Luc,
Again, thanks for your time!
I downloaded the source of the article you provided, and found out that there is exactly the same happening as in my project.
Apart from that the article shows very well how a inherited ApplicationContext class can be modified for the Splash usage.
So thanks for the link!
I also posted the question in the article, maybe the autor is interested in that fact.
All the best,
Martin
|
|
|
|
|
I have a XML file. I want to open that XML file in browser, when i click on the button.
Help me out.....
|
|
|
|
|
FileStream fileStream = new FileStream("c:\\dat.xml", FileMode.OpenOrCreate, FileAccess.Read);<br />
<br />
long len;<br />
<br />
len = fileStream.Length;<br />
<br />
Byte[] fileAsByte = new Byte[len];<br />
<br />
fileStream.Read(fileAsByte, 0, fileAsByte.Length);<br />
<br />
<br />
Response.Clear();<br />
Response.ClearContent();<br />
Response.ClearHeaders();<br />
<br />
Response.Buffer = true;<br />
Response.ContentType = "text/xml";<br />
Response.BinaryWrite(fileAsByte);<br />
Response.Flush();<br />
Response.End();
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|