|
thank you
i find that i can use fill method
your Suggest is very good for me
my english is poor
so there are maybe some errors with english :;P
study everyday
|
|
|
|
|
I'm wondering how to display tabs or buttons for open documents in a multiple document interface.
For example, lets say there are 5 documents open in the MDI Container, and they are all maximized, there is no way to swap back and forth to the other documents.
What would be the best way to do this?
Thanks in advance,
Jon
|
|
|
|
|
You could add a Menu to the MDI Parent, call it, say, &Window, and set it MDIList property to true.
RageInTheMachine9532
|
|
|
|
|
I have made a windows menu for open windows, but this is not what I am trying to do. I need some kind of tab style control so that users can click on directly to swap back and forth, kinda like all good MDI applications.
|
|
|
|
|
Then you'll need to either create your own form classes and owner-draw these tabs, or use an existing library like Magic Controls which can be found here on CodeProject (along with other implementations). Magic Controls is now a commercial library, but an older, stable version is posted here for the CodeProject community.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have 3 radiobuttons on a form, when i do this in the code:
if ((optWin32.Checked) or (optWin32Unix.Checked))
i get 2 mistakes:
'Lay_out.frmSessions.optWin32' denotes a 'field' where a 'class' was expected<br />
<br />
The name 'or' does not exist in the class or namespace 'Lay_out.frmSessions'
what can i do about it?
thx in advance
|
|
|
|
|
or is not part of the C# language. You should use the boolean operator || instead. See this web site for a list of operators in C#[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event[^].
|
|
|
|
|
Hello,
i'm trying to connect a DataGrid with a query that read a table of an MDB Access database. I've used OleDbConnection, OleDbDataAdapter and DataSet to access via the OLEDB 4.0 Provider the file. After that i can see the records.
The code, used in Form Load is:
<br />
connection1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Temp\\Brick1.MDB");<br />
<br />
dataadapter1 = new OleDbDataAdapter("SELECT * FROM [Articles];", connection1);<br />
<br />
dataset1 = new DataSet("DataSetTest");<br />
dataadapter1.Fill(dataset1, "articles");<br />
<br />
dataGrid1.DataSource = dataset1.Tables["articles"];<br />
The problem is that if i change some cell value, than i close the window and reopen, i cant see any change of mine. Is there a simple way to update the data at every cell change or when selection is moved on a new row? i cant see any update events on the DataGrid component.
I've searched for tutorials about this but i cant find anything about "forcing data update" from the grid.
|
|
|
|
|
Gian wrote:
there a simple way to update the data at every cell change or when selection is moved on a new row? i cant see any update events on the DataGrid component.
CurrenCellChaneged event.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
The DataGrid is only a view on the data. The CurrentCellChanged event isn't really the place to update the database with your changes, which you must do manually. Changing values in the DataGrid will change your DataSet , but you must update the database with those changes using OleDbDataAdapter.Update , which requires that you assign the necessary properties like InsertCommand , UpdateCommand , and DeleteCommand , besides the required SelectCommand . If you don't update the database, then when you re-get your DataSet it won't have any changes. This is not automatic.
Again, the CurrentCellChanged is fired too often and should not be used to update your database. Instead, do that when the form is closed or use a button who's Click event handler updates the database.
See the OleDbDataAdapter class documentation for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi!
I have produced a class library with documentation (<summary> , <param > ...) of any type and member. But after compiling it, my documentation is lost.
How can I include my documentation into my comiled assembly, so that it appears in IntelliSense and Object Browser??
|
|
|
|
|
You can define a path for the assemblyname.xml file in your project's properties.
If this XML documentation has the same name as the DLL, IntelliSense will find it in the folder that contains the assembly and display the summaries.
|
|
|
|
|
Go into your Project Properties, Configuration Properties, Build, and make sure that XML Documentation File is set to the same filename with an XML extension as your assembly. For instance, if your target filename is myAssm.DLL, then your XML Doc filename should be myAssm.DLL.XML.
RageInTheMachine9532
|
|
|
|
|
Actually, just myAssm.xml is fine. This is how the FCL XML documentation is named as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
XmlNode test = xml.SelectSingleNode("/session/parameters/developmentsession");<br />
if (test.InnerText.ToString() = "true")<br />
chkDevelopment.Checked = true;<br />
else chkDevelopment.Checked = false;
what is wrong with this if-structure? The compiler says
Cannot implicitly convert type 'string' to 'bool'
Thx in advance
|
|
|
|
|
do you mean this :
if (test.InnerText.ToString() == "true")
|
|
|
|
|
yes that's it
sorry stupid mistake
|
|
|
|
|
Actually, that's not really correct, either. What if it's "True"? It's better to use Convert.ToBoolean(String) or something like that, if all you're expecting is a boolean string, or false for anything else that isn't some variant of "true".
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
When you do string comparisons, the string class has a static method to help you. Try the following:
XmlNode test = xml.SelectSingleNode("/session/parameters/developmentsession");
if(string.Compare(test.InnerText, "true", true) == 0)
chkDevelopment.Checked = true;
else
chkDevelopment.Checked = false;
- Nick Parker My Blog | My Articles
|
|
|
|
|
I've asked this question a month ago, but have had the flu , so now I try again.
I used this code and compiled it in VS2002 and it works fine.
#region Key events
protected override void OnKeyDown(KeyEventArgs kea)
{
switch (kea.KeyData)
{
case Keys.Enter:
...
..
break;
case Keys.Escape:
this.Close();
break;
}
}
#endregion
The class is deriving from System.Windows.Forms.Form
I then compiled it in VS2003 and it woudn't enter the method when I make
a key event like Esc or any other.
Anyone knows why?
Thanks
Thomas
|
|
|
|
|
Either it's not loaded or there was some breaking change. Read the Visual Studio 2003 documentation (not the .NET Framework SDK, mind you) for more information on the DTE object model to see if anything has changed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have a structure defined in a dll which has another structure array as a member. I need to call this Dll from C#. How do I do it?
This is the structure I have in the DLL.
typedef struct FIRST_STRUCT
{
double XSpeed;
int DRate;
unsigned int RotCtrl
} FIRST_STRUCT;
typedef struct SEC_STRUCT
{
char Model[20];
unsigned int SuptTxt;
FIRST_STRUCT CurSpd;
FIRST_STRUCT MaxRdSpd;
unsigned int cNumSpd;
FIRST_STRUCT CrwWrd[40];
FIRST_STRUCT DWrd[20];
} SEC_STRUCT;
__declspec (dllexport) unsigned int CALLBACK MyFunc(SEC_STRUCT * Info);
_________________________________________________________________________
How do I call this from my C# client? I have changed the structure as
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct First_struct
{
public System.Double XSpeed;
public System.Int32 DRate;
public System.UInt32 RotCtrl;
}
How do I marshal the SEC_STRUCT in C#. I tired using the MarshalAs(), but it gave me a run time error 'System.TypeLoadException'
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)]
public First_struct[] CrwWrd;
Kindly Help.
Thanks
Vini
|
|
|
|
|
What was the full message of the exception?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
What was the full message of the exception?
An unhandled exception of type 'System.TypeLoadException' occurred in MyProj.exe
Additional information: Can not marshal field CrwWrd of type FIRST_STRUCT: This type can not be marshaled as a structure field.
kindly help..
Vini
|
|
|
|
|
Marshalling nested structs is not supported in the .NET Framework. Instead, you need to marshal them as IntPtr s using Marshal.StructureToPtr and back using Marshal.PtrToStructure :
[StructLayout(LayoutKind.Sequential)]
public struct FirstStruct
{
[MarshalAs(UnmanagedType.R4)] public double XSpeed;
[MarshalAs(UnmanagedType.SysInt)] public IntPtr DRate;
[MarshalAs(UnmanagedType.SysUInt)] public IntPtr RotCtrl;
public FirstStruct(double XSpeed, long DRate, long RotCtrl)
{
this.XSpeed = XSpeed;
this.DRate = new IntPtr(DRate);
this.RotCtrl = new IntPtr(RotCtrl);
}
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public struct SecondStruct : IDisposable
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=20)] public string Model;
[MarshalAs(UnmanagedType.SysUInt)] public IntPtr SuptText;
public IntPtr CurSpd;
public IntPtr MaxRdSpd;
[MarshalAs(UnmanagedType.SysUInt)] public IntPtr cNumSpd;
public IntPtr CrwWrd;
public IntPtr DWrd;
public SecondStruct(string Model, long SuptText, FirstStruct CurSpd,
FirstStruct MaxRdSpd, long cNumSpd, FirstStruct[] CrwWrd,
FirstStruct[] DWrd)
{
if (CrwWrd == null || DWrd == null)
throw new ArgumentNullException(CrwWrd == null ? "CrwWrd" : "DWrd");
if (CrwWrd.Length > 40) throw new ArgumentException("Error", "CrwWrd");
if (DWrd.Length > 20) throw new ArgumentException("Error", "DWrd");
this.Model = Model;
this.SuptText = new IntPtr(SuptText);
this.cNumSpd = new IntPtr(cNumSpd);
GCHandle handle = GCHandle.Alloc(CurSpd);
this.CurSpd = handle.AddrOfPinnedObject();
handle = GCHandle.Alloc(MaxRdSpd);
this.MaxRdSpd = handle.AddrOfPinnedObject();
handle = GCHandle.Alloc(CrwWrd);
this.CrwWrd = handle.AddrOfPinnedObject();
handle = GCHandle.Alloc(DWrd);
this.DWrd = handle.AddrOfPinnedObject();
}
void IDisposable.Dispose()
{
GCHandle handle = (GCHandle)this.CurSpd;
if (handle.IsAllocated) handle.Free();
handle = (GCHandle)this.MaxRdSpd;
if (handle.IsAllocated) handle.Free();
handle = (GCHandle)this.CrwWrd;
if (handle.IsAllocated) handle.Free();
handle = (GCHandle)this.DWrd;
if (handle.IsAllocated) handle.Free();
this.Model = null;
GC.SurpressFinalize(this);
}
}
[return: MarshalAs(UnmanagedType.SysUInt)]
public delegate IntPtr MyFunc(ref SecondStruct Info); This should work. If you have problems with it, see http://www.dotnet247.com/247reference/msgs/24/121227.aspx[^] for another way where you actually alloc each struct and struct array member in global memory. Since structs are allocated on the stack, I only pin and get the address of the first member (the array address) since the unmanaged code should easily get the array from the start address. You might want to add additional code to make sure, however, that the arrays are exactly 40 or 20 elements in size.
Microsoft MVP, Visual C#
My Articles
|
|
|
|