|
Can anyone point me in the right direction for declaring a RichTextBox column within a DataGridView...
I know there are a few examples revolving around the Calander control... but... these examples all revolve around editable controls... the displayed control remains a TextBox until it is clicked... which is no good for me... as I want to display each cell as a RichTextBox.
I assume my only option is to derive from DataGridViewCell and override Paint... but my c# is little weak and I'm struggling.
In addition, I may be using a hammer to crack a nut... as all I want to do is to display text in a column which may have some words underlined... from my limited understanding of .net controls... I can only do partial underline with a RichTextBox... thus the need to create a RichTextBox column.
Thanks for anyone who actually reads this... and a double thanks for anyone who replies.
|
|
|
|
|
|
Okay, I have this function that I want to run, it's pretty simple, but for the life of me, It's not working, can someone take a look at it and let me know what you think? It's like connectionStr never gets set, yet the way I call it is MysqlNonQuery("SELECT * FROM account", 1);
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using MySql.Data.MySqlClient;<br />
<br />
namespace mangosAdmin<br />
{<br />
class functions<br />
{<br />
public static string MysqlNonQuery(string sql, int db)<br />
{<br />
string connectionStr;<br />
<br />
if (db == 1)
{<br />
connectionStr = "Database:" + Properties.Settings.Default.mangosDB + ";Source=" + Properties.Settings.Default.mangosHost + ";User Id=" + Properties.Settings.Default.mangosUser + ";Password=" + Properties.Settings.Default.mangosPass;<br />
}<br />
else if (db == 2)
{<br />
connectionStr = "Database:" + Properties.Settings.Default.realmDB + ";Source=" + Properties.Settings.Default.realmHost + ";User Id=" + Properties.Settings.Default.realmUser + ";Password=" + Properties.Settings.Default.realmPass;<br />
}<br />
else<br />
{<br />
connectionStr = "Database:" + Properties.Settings.Default.mangosDB + ";Source=" + Properties.Settings.Default.mangosHost + ";User Id=" + Properties.Settings.Default.mangosUser + ";Password=" + Properties.Settings.Default.mangosPass;<br />
}<br />
try<br />
{<br />
MySqlConnection myConnection = new MySqlConnection(connectionStr);<br />
MySqlCommand myCommand = new MySqlCommand(sql);<br />
myCommand.Connection = myConnection;<br />
myConnection.Open();<br />
myCommand.ExecuteNonQuery();<br />
myCommand.Connection.Close();<br />
}<br />
catch (MySqlException ex)<br />
{<br />
return(ex.Number+ex.Message);<br />
}<br />
<br />
return ("0");<br />
<br />
<br />
}<br />
<br />
<br />
}<br />
}<br />
|
|
|
|
|
What's the actual error that you're getting from your code?
|
|
|
|
|
i encrypt my database(access) and when my project is running , the database is decrypt and copy on system32 , and after that when the project is closing i delete the database on system32 folder .
it is ok on my computer , but when i run it on another computer , the db decrypt successfully , but in one of my function which i use connection.open , show following error :
could not use ;file already in use
how could i solve this error?!!!
|
|
|
|
|
Make sure that the method that creates the file closes it properly.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
if that method dosn't close it, why there is not any problem on my computer?
|
|
|
|
|
There can be many different reasons why code that is not completely correct may work in one place but not another.
Among possible reason can be different file systems, different memory load, different cpu load, different operating systems.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
You said you're putting this database in the \Windows\System32 folder? Did it occur to you that not every user account has full access to that SYSTEM folder? You might want to pick a better place to put that database before you try and access it, like in the root of the Users profile or in the Temp folder. Even if all you're doing is querying the Access database and not making any changes to it, you still need full read/write permissions to the FOLDER that the .MDB file is in.
And for why it works on your dev machine and not on others - did you develop your app under an Admin account?? Not a good idea - even though most developers do this...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
both computer have the same os , and i login as admin in both computer so it is not for permission .
|
|
|
|
|
Hi,
I have a class which uses async sockets functions (i.e. BeginXXX ).
One of the functions in my class for example is Listen() .
In my callback functions I would like to fire events.
These events could sometimes be used to control the UI.
So what I'm looking for is a way to invoke the events on the calling thread instead of the callback's thread.
I thought of holding a reference to a Control object inside my class.
This reference would be sent to my class through the constructor, and I could then call Invoke() on it.
But what if its not a Control which called my Listen() function?
Is there any way to know which thread is the calling thread, and invoking the events on it?
Thanks in advance,
Shy.
|
|
|
|
|
Hi Shy,
You can't really invoke the callback function on the calling thread, as that would have to be invoked Synchronously.
I'm assuming the reason you are trying to do this is because you can only manipulate GUI components from the thread they were created on (Static compartment). If this is the case, then you don't need to worry about using the calling thread to throw the events.
Instead, raise the events, and supply a delegate to the application Form, Form.Invoke(myDelegate)
This will run whatever code you need executing on the forms creating thread which will do any UI manipulations you need.
If that's not what you wanted, shout back and i'll have another look.
Tris
|
|
|
|
|
Tristan Rhodes wrote: Instead, raise the events, and supply a delegate to the application Form, Form.Invoke(myDelegate)
Hmm... Not really sure what you mean...
Could you please give me an example?
In the meanwhile, I did the following, but I'm not really sure this is the right way:
class TCPSocket
{
public event ConnectedEventHandler Connected;
private Control user;
public TCPSocket(...) { ... }
public TCPSocket(..., Control user)
{
...
this.user = user;
}
private void RaiseConnectedEvent(IPEndPoint ep)
{
if (Connected != null)
{
if (user != null)
user.Invoke(Connected, ep);
else
Connected(ep);
}
}
} In my callbacks I use my RaiseXXXEvent() methods.
So basically this is how I invoke all of my events...
I'd be glad to hear your opinion about my code...
Is there something wrong with what I'm doing?
|
|
|
|
|
Hi Shy,
I think the layouts a bit skewed.
You shouldn't really need to supply the control if the control can subscribe to the event.
try just using:
<br />
private void RaiseConnectedEvent(IPEndPoint ep)<br />
{<br />
if (Connected != null)<br />
{<br />
Connected(ep);<br />
}<br />
}<br />
Then subscribe the relevant form to the event
<br />
class MyForm<br />
{<br />
TCPSocket socket;<br />
Control myControl;<br />
<br />
private void SocketEventHandler(object sender, SocketEventArgs e)<br />
{<br />
<br />
me.Invoke(RunGuiThing);<br />
}<br />
<br />
private void RunGuiThing()<br />
{<br />
myControl.BackgroundColor = Color.Green;<br />
}<br />
}<br />
<br />
Hope that solves it
Tris
|
|
|
|
|
Indeed, that is possible.
I just thought I'd add a built in functionallity to invoke the events on the GUI thread.
|
|
|
|
|
Ah!
In that case - this should work:
<br />
class TCPSocket<br />
{<br />
public event ConnectedEventHandler Connected;<br />
<br />
private Control user;<br />
<br />
public TCPSocket(...) { ... }<br />
<br />
public TCPSocket(..., Control user)<br />
{<br />
...<br />
this.user = user;<br />
}<br />
<br />
private void RaiseConnectionEvent(IPEndPoint ep)<br />
{<br />
if (user != null)<br />
user.Invoke(this.Invoker, new object[]{ep});<br />
else<br />
this.OnRaiseConnectedEvent(ep);<br />
}<br />
<br />
protected virtual void OnRaiseConnectedEvent(IPEndPoint ep)<br />
{<br />
if (Connected != null)<br />
{<br />
Connected(this, ep);<br />
}<br />
}<br />
<br />
private void Invoker(IPEndPoint ep)<br />
{<br />
OnRaiseConnectedEvent(ep)<br />
}<br />
}<br />
Tris
|
|
|
|
|
Hmm...
Why do we need the proxy Invoker() method?
user.Invoke() can accept an event as the 1st parameter, so why send it a function which raises the event?
Am I missing something here?
|
|
|
|
|
Hmm, didn't know that, but it makes sense.
I think the delegate route makes it more flexible if you want to add info in the EventArgs with details about the executing thread.
I'm not actualy sure what you're asking, the origional version would have worked, so what is the problem?
Tris
|
|
|
|
|
Well, I just wanted an opinion on my code, as I wasn't sure it's a good practice to send a Control object to the constructor.
I think I'll hold a reference to System.ComponentModel.ISynchronizeInvoke instead of a Control object, so it would be more generic...
Anyway... Thank you very much!
Much appreciated!
|
|
|
|
|
Cool, np.
Good luck, let me know how it all ties up.
T
|
|
|
|
|
Hi,
There is a project with classes (businessLayer) referenced from the clients (WinForms) project. So the BusinessLayer dll is sitting on the client. What happens if the businessLayer changes in the future? How will the clients pick up the new dll?
Please note that for business purposes this is how the solution is setup.
Thanks
|
|
|
|
|
i use AxShockwaveFlashObjects in VS.net 2003 , but when i run the exe of this project , on framework 2 , this object cause error!!!!!!!!
why?
how could i solve this problem!!!
|
|
|
|
|
I use AxShockwaveFlash object in C# , and when the user click the right button of mouse on it , he/she can see the flash menu ,how could i hide this menu?
|
|
|
|
|
Put Stage.showMenu = false; in the first frame of your flash.
|
|
|
|
|
thanks , but it dosent work on win app. im using flash object in windows application.
|
|
|
|