|
Well, with C# you could use a verbatim string with an @ in front of it and you would only need two backwards slashes.
-Nick Parker
|
|
|
|
|
How can I insert a row into a datagrid control that is bounded to a datatable? For clarification, by insert, I mean creating an empty row in the middle of the displayed filled-up rows. Having searched all the websites and entire MDSN library, I would greatly appreciate any tips on this. Thanks!
|
|
|
|
|
Set a handler for the ItemCreated or ItemDataBound and insert the row you want.
|
|
|
|
|
Ok I have a simple function used to resize and create thumbnails. I build the file in vs.net, CreateThumb.cs. Now how do I go about calling that function from an asp page?
I suppose I need to register the DLL etc...so I can call the function in my asp page? Need the syntax for that.
Call CreateThumb(param)
Please help!
Thanks,
Jordan
|
|
|
|
|
jrmcdona wrote:
I suppose I need to register the DLL etc...so I can call the function in my asp page? Need the syntax for that.
It doesn't really work like that. To get a .NET assembly .dll to load in a regular ASP page is a little difficult (though it can be done, check my article Creating a RCW for COM enabled non .NET applications[^] ). Otherwise if you are creating an ASP.NET page, you can simply create an instance of your class and start using it.
-Nick Parker
|
|
|
|
|
Also, the assembly either has to be dropped into the ASP.NET Web Application's private path (usually bin) or installed into the GAC (use gacutil -i <assemblyName> or drag it into \windows\assembly).
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
Hello Gurus,
Can anyone give me some good sources on this topic?
Thanks so much
Khang Nguyen
|
|
|
|
|
Use DataGridTableStyles . You can easily do this during design-time with the DataGrid.TableStyles property. You can have multiple table styles, each bound to a different DataMember name (usually tables of a DataSet or something). Within each of these table styles, you specify each column and bind them to a DataColumn name (for each row of the table to which the style is bound). Programmatically, the same procedure is used. Lets say you want the last column of the first table style to be 100 pixels:
int count = dataGrid1.TableStyles[0].GridColumnStyles.Count;
dataGrid1.TableStyles[0].GridColumnStyles[count - 1].Width = 100;
This is for a System.Windows.Forms.DataGrid and can use other data sources other than a DataSet since table styles themselves don't have to bind to any data member and you can just specify the grid columns bound to certain columns / properties in whatever data source you use.
Now, if this is a System.Web.UI.WebControls.DataGrid , you have to use template styles.
In either case, try it in the visual designer, look at the code produced in the source file, and read the docs so you understand exactly what you're reading. It's not that hard and you can customize a lot without overriding anything.
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
Thank you so much, Health. Your tip is very helpful!
|
|
|
|
|
I have an Extension DLL create from MFC which consists of so many exported classes and would like to be able to use them on my c# project. I know since this is not a pure COM Object and therefore i can't use tlbimp.exe to create Runtime callable Wrapper class for it. As I was reading about Platform Invocation Service (PInvoke) and my question is,
can i export classes from my dll through PInvoke? Or just functions that can be imported from PInvoke? Any Suggestions will be much appreciated.
|
|
|
|
|
|
Leppie,
Can you explain to me a bit about MC++ Mixed mode?
thanks
|
|
|
|
|
|
I have problem. When I try to read the records of the 'MSysObjects' table in my access db, I receive this error message:
Run-time error '3112':
Record(s) can't be read; no read permission on 'MSysObjects'
I know that MSysObjects is a system table, but I don't know why I can't read its records.
I write this code:
/**************************************************************************/
m_oleDBConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+szMDBFileName+";";
m_oleDBConnection.Open();
string t_Clause = "SELECT * FROM MSysObjects WHERE Flags = 0 AND Type = 1";
System.Data.OleDb.OleDbCommand t_Select = new System.Data.OleDb.OleDbCommand(t_Clause, m_oleDBConnection);
try
{
System.Data.OleDb.OleDbDataReader t_Reader = t_Select.ExecuteReader();
}
catch (OleDbException e)
{
string errorMessages = "";
for (int i=0; i < e.Errors.Count; i++)
{
errorMessages += "Index #" + i + "\n" +
"Message: " + e.Errors[i].Message + "\n" +
"NativeError: " + e.Errors[i].NativeError + "\n" +
"Source: " + e.Errors[i].Source + "\n" +
"SQLState: " + e.Errors[i].SQLState + "\n";
}
/**************************************************************************/
Can you tell me please what's the problem ?
Thank you very much for all answer.
|
|
|
|
|
Hello my Gurus,
I could not figure out why my DataSet, more specificly my [M-T] table is not updated at all and no exceptions generated.
iNumOfAffectedRecs is always = 0;
Did I miss something?
Thanks in advance
Khang Nguyen
=================================================================================
private void btnTestUpdate_Click(object sender, System.EventArgs e)
{
MDSConnection MDSConn = new MDSConnection();
OleDbConnection conn = MDSConn.GetCon(); // conn is already open!
string sQuery = "SELECT * FROM [M-T]";
OleDbDataAdapter adapter = new OleDbDataAdapter(sQuery, conn);
DataSet dataSet = new DataSet("Update_DataSet");
adapter.Fill(dataSet);
Console.WriteLine("[M-T] rows = " + dataSet.Tables[0].Rows.Count);
DataRow row = dataSet.Tables[0].NewRow();
row["ModuleID"] = "LK-STT1"; // text
row["TaskID"] = 791; // number
dataSet.Tables[0].Rows.Add(row);
dataSet.Tables[0].AcceptChanges();
Console.WriteLine("[M-T] rows = " + dataSet.Tables[0].Rows.Count);
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(adapter);
// adapter.Update(dataSet, dataSet.Tables[0].ToString());
int iNumOfAffectedRecs = adapter.Update(dataSet);
MDSConn.Cleanup(); // con is closed
}
|
|
|
|
|
Yes, this line shouldn't be there:
dataSet.Tables[0].AcceptChanges();
DataAdapter objets look for changes to the DataSet and only update what's been changed (inserted, updated, and deleted). When DataAdapter.Update completes, it will automatically call DataSet.AcceptChanges .
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
Thanks again, Guru! Let's me try it out.
Khang
|
|
|
|
|
C# seems to use a lot of memory (compared to some of my C++ programs that do similar things.) I was just wondering what you all have observed and I would love to hear the comments of any Java programmers out there. Does Java’s garbage collection work better/faster….. ? (I hope this last question does not start a religious flame war.)
Is there some way to “view” a running C# app in Visual Studio and see what objects have a reference (and therefore are not up for garbage collection)?
|
|
|
|
|
I think I've read somewhere that the reason for it is the extremly large header included with the .NET framework. If for example you create an MDI application which spawns child windows inside the parent those new windows wont take a lot of memory.
|
|
|
|
|
Yes, I have noticed this too...I've assumed it was related to the .Net framework. I have used Java before this, though, and I think it was even more memory hungry.
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
I'm trying to make an app that catches the clipboard data when somebody press print screen. The problem I'm facing is to determin if the user has pressed print screen, the event needs to be triggerd even if my app doesn't have focus. So what I'm wondering is if there's any reliable way to do this without hooks and that sort of stuff (which I know nothing about hehe). All I need is some keywords or perhaps a good article/tutorial .
just figured it out, no need to answer this one.
|
|
|
|
|
Since your application doesn't worn the desktop window, you'd have to set a Windows hook. They're not as hard as you think, and MSDN even has examples. Lookup the functions SetWindowsHookEx and UnhookWindowsHook . The topic "Win32 Hooks" even has sample code.
Another way might be to P/Invoke the functions SetClipboardViewer and ChangeClipboardChain . Then call SetClipboardViewer with your window handle (Form.Handle.ToInt32() ). When the clipboard is changed, your application is sent the WM_DRAWCLIPBOARD message (DWORD, 0x0308). You must also P/Invoke SendMessage so that when WM_CHANGECBCHAIN is passed (when the clipboard chain changes, i.e. a viewer is added or removed) you can pass the HANDLEs that you received from calling SetClipboardViewer . This may sound complicated, but it's not. Essentially, you're just inserting yourself in a chain and handling messages passed to that chain. When you get the WM_DRAWCLIPBOARD message, you can use all the .NET class library's members for accessing the clipboard, checking for DataFormats.Bitmap or some other string (even your own). This would tell you that an image was copied, though, not that the PrintScreen key was pressed.
You could compare the size of the image with the size of the screen, but that only gives you a probable screenshot.
Basically, a windows hook is the way to go if you want a true handle for PrintScreen. The other is just an alternative if you just want to know when an image was copied to the clipboard.
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
thx, I'm looking into it
|
|
|
|
|
I am writing an application that has two modes 1) Normal Windows Forms based UI operation, 2) batch mode no UI mode operation using the same codebase.
On application start I would like to test for a parameter, and, or read a configuration file flag to determine which mode to operate under, then if UI mode, instantiate the main form and operate Windows application normal. If batch mode, either branch to other application logic or operate with the main form minimized or invisible. To do this, I would like to launch the application from a non-form based class like AppStart.cs with the application main method hosted there instead of in the main form, and I would like to show a Splash screen while I do some setup configuration work before before real processing begins . So the flow would be like this:
1. Main method kicks in from generic class...
2. New thread is started to manage splash screen based on a timer...
3. Configuration file is read to check batch mode flag...
4. If mode is UI, then when Splash timer is finished do Application.run and instantiate main form...
5. If mode is Batch, then either instantiate main form invisible, or run the applicaion without the main form...
Can anyone point me towards and example of starting a windows application from a main class instead of from a form? I thing this will have something to do with using the application context, and threads to do what I'm trying to do...?
Thanks!
|
|
|
|
|
Hi. I have a combo box, that when the selection is changed, I dont want it to do anything (at the moment, as I am using dataBinding, it tries to change the index, as I have a listBox with different categories, and the comboBox changes that category). I want to it to stay in the same place until the user clicks on an update button. Anyone know how to achieve this?
|
|
|
|