|
By the way, I've done quite a bit of grid before. Using a simple custom cell drawing is nothing new to me. I understand that I dont need a control to get the cell to pain properly. The reason I want to have a control is because I need a real control to interact with when the cell is focused.
I was hoping that someone knew how to "abuse" the painting code of the control to get the control to paint itself into a certain area of my grid without having to actually create a million instances of the control and aligning them to form a grid.
|
|
|
|
|
Actually you extend the datagridColumn class. Once there you can override paint methods for drawing, add controls and use GetValueAtRow and SetValueAtRow.
www.syncfusion.com has a faq thats excellent for this
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I got it figured out. Thanks for trying guys.
A clue for others that need to do something similar. Use native methods. 1. Get WindowDC 2. Create compat bitmap 3. select the object 4. Send WM_PRINT message to window specifying the memory DC as the device context
|
|
|
|
|
I want to remove a row from my database based on the instance of a title.
For example if i enter win32newb as the title it will filter the database to only include that row and delete it. Here is what i have in my code but it doesn't work. It throws an exception saying the current status is closed.
private void removebutton_Click(object sender, System.EventArgs e)
{
string strSQL = "DELETE * FROM Movie WHERE Title = ";
strSQL += searchbox.Text;
oleDbDeleteCommand1.CommandText = strSQL; //add the string to deletecommand
oleDbDataAdapter1.DeleteCommand = oleDbDeleteCommand1;
oleDbDeleteCommand1.Connection = oleDbConnection1;
oleDbDeleteCommand1.ExecuteNonQuery();
}
If you know of an easier method I'm open for suggestions. Anything that works pretty much. Thanks. Also, how would i make it where if the title that is entered doesn't exist it would not execute cause wouldn't that throw an exeception also if the title doesn't exist?
Thanks in again
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
win32newb wrote:
oleDbDeleteCommand1.Connection = oleDbConnection1
Best is to open and close the connection just before and after the "executenonquery".
win32newb wrote:
Also, how would i make it where if the title that is entered doesn't exist it would not execute cause wouldn't that throw an exeception also if the title doesn't exist?
Use a try/catch
top secret
|
|
|
|
|
thanks for the reply. I have a question maybe you or someone else can help with. Either my sql statement is not correct or something. I keep getting an exception because the catch keeps showing up.
I have a database with a table called Movie and it has fields Information and Title.
I have a test value in there called tony.
thanks for the help.
try
{
string strSQL = "DELETE * FROM Movie WHERE Title = ";
strSQL += searchbox.Text;
oleDbDeleteCommand1.CommandText = strSQL;
oleDbDataAdapter1.DeleteCommand = oleDbDeleteCommand1;
oleDbDeleteCommand1.Connection = oleDbConnection1;
oleDbDeleteCommand1.Connection.Open();
oleDbDeleteCommand1.ExecuteNonQuery();
oleDbDeleteCommand1.Connection.Close();
}
catch
{
MessageBox.Show("Not found");
}
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
win32newb wrote:
catch
{
MessageBox.Show("Not found");
}
replace that with:
catch (Exception ex)
{
MessageBox.Show(ex.Tostring());
}
You will get a MUCH better error condition, and if you dont know what to do with it, I'm sure many a person on CP will be able to help
top secret
|
|
|
|
|
thanks i was wondering how to use that. i'm very new to this c# amazes me i konw this much haha.
anyway i got it working.
try
{
string strSQL = "DELETE FROM Movie WHERE Title = '" + searchbox.Text + "'";
oleDbDeleteCommand1.CommandText = strSQL;
oleDbDataAdapter1.DeleteCommand = oleDbDeleteCommand1;
oleDbDeleteCommand1.Connection = oleDbConnection1;
oleDbDeleteCommand1.Connection.Open();
oleDbDeleteCommand1.ExecuteNonQuery();
oleDbDeleteCommand1.Connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Not found");
MessageBox.Show(ex.ToString());
}
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
Dear Sir,
Ihope that this mail finds you in good shape. Well, the thing is that I am really very depressed and dishearted these days. I am a student doing my BS in Computer Science and next week I've to submit my c# project.
The onle problem I'm facing is that
!! HOW DO WE RUN a FLASH MOVIE in a C#SHARP APPLICATION?
I've tried everything. it gives an error.
Object Reference Not Set To an Instance of an Object.
Any Solutions,
Please send them to me
Truly Yours,
Imad
Imad
|
|
|
|
|
Just reference the FlashActiceX component.
top secret
|
|
|
|
|
The thing is that, I have already imported a Com Control by the name of Shockwave Flash Objects. but as soon as I embed and run this control in my C# Windows Application the .NET Framework Crashes.
Please help me out What should I do?
itsimad@hotmail.com
Imad
Imad
|
|
|
|
|
I am trying to create a binary file but the binarywriter doesnt work and its a pdf so I believe it has to be true binary with no unicode style delimiters. Do I need to write c++ code in my assembly or does c# have a way?
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
I am trying to create a binary file but the binarywriter doesnt work and its a pdf so I believe it has to be true binary with no unicode style delimiters.
What are your trying to write to a file? What is PDF, I thought u are writing a file. Why unicode appear in a binary file?
Ista wrote:
Do I need to write c++ code in my assembly or does c# have a way?
I think you need to look for Dorothy, the lion and the tin man, perhaps they can tell you.
top secret
|
|
|
|
|
leppie wrote:
I think you need to look for Dorothy, the lion and the tin man, perhaps they can tell you.
A little rough, isn't it?
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nick Parker wrote:
A little rough, isn't it?
Not rough enough it appears!
top secret
|
|
|
|
|
I think dorothy would be of more assistance to you.
pdf is just text written to a binary file. The BinaryWriter writes in unicode which is standard in .net.
And when you write a file in .net it leaves unicode delimiters without special formatting.
Its really a simple question if you read it.
I need to create a binary file. How do you do that in c#. As of current I think c++ is the only way.
And yes the lion is someone with at least an advanced background with an understanding of files which hasn't read my question yet.
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
|
And yes the pdf code in which I have written was based on the document downloaded from that page.
and yes it is text file saved as a mac binary format.
If you know how to write a binary file I would really appreciate you telling me. I already know the fundamentals.
thanks,
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
and yes it is text file saved as a mac binary format.
Ahhh, now we getting some where
The problem u have is that the current file contains mac line endings (\r), and these just need to be converted to (\n\r). This could be as easy as using a TextWriter.WriteLine(TextReader.ReadLine()) to go thru the whole file (this works at least for Unix->DOS conversion).
Else you will have to feed the content into a string and replace all the occurances, and save it to a text file (not binary, that is used for saving primitives to a bytestream).
top secret
|
|
|
|
|
yeah basically. So in conclusion you can't create one in .NET unless you use c libraries because of the fact that when streams deserialize they leave meta data thus corrupting the file. You could never get the file to be rid of the delimiters without using C++.
Thanks for the input, but the answer is without the use of unsafe code "no".
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
You could never get the file to be rid of the delimiters without using C++.
I just said how to do it in C#.
Ista wrote:
So in conclusion you can't create one in .NET unless you use c libraries because of the fact that when streams deserialize they leave meta data thus corrupting the file.
What leads you to this conclusion, it's absurd?
top secret
|
|
|
|
|
Well duh, a stream adds its own formatting at the end. I opted to use ansi c calls in a c++ managed dll.
So if theres an easy way in c# to write a file without creating a stream I know of none.
And besides the conclusion has no fault, seeing that you failed to point one out other than give an absurd answer.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
Well duh, a stream adds its own formatting at the end.
WTF are u talking about? End of what? Stream is a wrapper around FILE*. You are doing something wrong, and not being specific.
Ista wrote:
And besides the conclusion has no fault, seeing that you failed to point one out other than give an absurd answer.
I have been trying to help you, but you are being the stubborn one.
top secret
|
|
|
|
|
well yeah its a wrapper. But the ofstream class adds about 15 characters to the end of the file when it writes for the serialization format. Create one and look at it, its there.
Either way I created a dll that uses the FILE object to write the file and it works fine.
I'm tired of a conversation in which it keeps stepping back even after a valid answer that started off with a flippant answer and I kept it going with even worse replies.
I answered my question and I don't know of any c# function that actually wraps a FILE object using ansi c calls other than a stream which wraps ofstream which wraps FILE thereby creating metadata at the end of the file.
I appreciate your time, but this topic is deemed useless now.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
The BinaryWriter writes in unicode which is standard in .net.
Only if you tell it to. It uses UTF-8 as default.
"BinaryWriter Constructor (Stream)
Initializes a new instance of the BinaryWriter class based on the supplied stream and using UTF-8 as the encoding for strings."
Ista wrote:
I'm not an expert yet, but I play one at work. Yeah and here too.
If I was you I would hope your boss dont browse CP...
top secret
|
|
|
|