|
I have it! I've been trying to make it work since Friday, and finally found what I've been doing wrong. This code in the Navigate event handler will do the trick:
private void dataGridModules_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
if(this.dataGridModules.DataMember.IndexOf("name-of-the-table")!=-1)
{
CurrencyManager cm=(CurrencyManager)
this.dataGridModules.BindingContext
[this.dataGridModules.DataSource,
this.dataGridModules.DataMember];
((DataView)cm.List).AllowNew=false;
}
}
My problem was that I was using only the name of the table for the BindingContext indexer, when I replaced it with this.dataGridModules.DataMember it started to work .
Rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
Hy everyone!
I know I already posted a lot of questions. I hope I did not anoy anyone of you, but I am very new to C#, trying to get along with my C/C++ knowledge, but C# is different in some ways. I also do have the MSDN to look up some things, but I don't know why, because if I do not know for sure what to look for (a class e.g.) then I feel lost in there .....
On the otherhand I should have finished a special task (a programm) at the end of August ....
Well but back to my question:
I do want to assign a field of an array of strings to a TextBox (the TextBox is called lTextBox in there and the field I want to assign is called ltemparray[1]).
The relevant code looks like this.
......
// definition
TextBox lTextBox = sender_txtNameKeyDragDrop as TextBox;
....
// part of the ContextMenu definition
menuItem1.Index=0;
menuItem1.Text=ltemparray[1].ToString();
menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
.....
// display contextmenu for the TextBox
ctNameKeyMenu.Show(lTextBox, lTextBox.PointToClient(Cursor.Position));
.....
private void menuItem1_Click(object sender_menuItem1Click, System.EventArgs e_menuI1C)
{
// assign data to TextBox in here
}
But the problem is: how do I get the TextBox. Well I do think I have to adress it via the parent, but I am not quit sure.
So if anyone of you could tell me what the lines of code to assign the string in the arrayelemnt to the TextBox (in the Click event) has to look like, it would help me a lot.
And besides I guess I would learn a lot!
Thanks!
Stephan.
|
|
|
|
|
Hy everyone!
I just did it!
But well, it's not perfect because at the moment I do use a global variable.
If someone of you knew a better solution please let me know.
My solution:
TextBox gsenderdst;<br />
......<br />
<br />
TextBox lTextBox = sender_txtNameKeyDragDrop as TextBox;<br />
....<br />
gsenderdst=lTextBox;<br />
menuItem1.Index=0;<br />
menuItem1.Text=ltemparray[1].ToString();<br />
menuItem1.Click += new System.EventHandler(this.menuItem1_Click);<br />
.....<br />
ctNameKeyMenu.Show(lTextBox, lTextBox.PointToClient(Cursor.Position));<br />
<br />
.....<br />
<br />
private void menuItem1_Click(object sender_menuItem1Click, System.EventArgs e_menuI1C)<br />
{<br />
MenuItem lsender=sender_menuItemClick as MenuItem;<br />
gsenderdst.Text=lsender.Text;<br />
}
Well as I said before I used a global variable and to me it doesn't look nice this way, but well, it works and that's what counts.
So if anyone of you knows a better solution (e.g. without the global) then please let me know!
Stephan.
|
|
|
|
|
Hello,
I am jayasree. I am working on speech processing device interface. I have a doubt in that. As i couldn't find relevant topic to post in in that, i have chosen this.
Presently I am taking data from waveIn device and looping it back to the waveOut device in the sound card. Now I am working on mixer interface. My doubt is is it possible to use LINE pin of the sound card. means is it possible to use as another destination when i am using both waveIn and waveOut devices. Or i have to bypass and use the same one.
As presently I am working on this, I need info about this very urgently.
jaya
|
|
|
|
|
Hi Gurus!
I writting some kind of Web Application and here I got a few WebForms and I need to exchange some variables between these pages. Usually when on page1 user pick up some value in Grid I wrote following code
Response.Redirect("../page1.aspx?MyVar="+textBox1.Text);
actually I just making a page redirect on itself and then in page class I defined private static string MyVar=""; and OnLoad I wrote
if(!this.IsPostBack)
{
if(Request["MyVar"]!="")
{
MyVar = Request["MyVar"];
DoSomeWork(MyVar);
}
}
So i want ot ask you is this optimal solution to store page variables? I mean maybe exists some better solution then redirect page on itself? Maybe I should use ViewState to store page variables or somth.?
xedom developers team
|
|
|
|
|
|
I would like to set up the formatting for hex to display as:
FF EE FF FD (instead of FFEEFFFD)
Also for Binary with digits in group of 8's
(i.e. 11111111 11101110 11111111 11111101)
these are to be displayed in editboxes.
Any Suggestion?
|
|
|
|
|
If I use inpout32.dll to access parallel port port on WinXP,
How can I use it in my source code?
Thanx
ahmedadel
|
|
|
|
|
hi guys,
i am new to C# programming. i want a small help. i have two tables in my sql database. suppose emp and salary.
In emp i have id,name and designation
In salary i have id and salary.
then coming to the problem i want to put up a form with 4 test boxes for id,name,designation and salary and databind.
Databinding works fine if it has only one table.(Simple Databinding)
But when i try to update both tables it gives error that id cannot take null value.
That is i want the id to be updated in both tables from a single textbox value.
Is it possible. How to go for that. This may seem simple to many. But i am new to all this, Help me.
Thanks in advance for ur help
hap
|
|
|
|
|
First - always bind to the DataSet , then set the binding member (like DataGrid.DataMember ) to the name of the DataTable when possible. This allows you to use relationships to navigate tables.
Second - the problem is that you haven't defined your DataTable yet. If your SQL database would use an identity field (auto-incrementing), then you must set the DataColumn.AutoIncrement property to true . The easiest way to do this is to add a new DataSet to your project in VS.NET and use the designer to create a DataSet . Create elements that represents DataTable s, and elements under those represent fields, which you can set properties for in the PropertyGrid. Then instead of using a generic DataSet , you can instantiate the DataSet derivative that you just created, which will - when instantiated - have the correct structure.
The problem you're having is that an identity column is not being assigned automatically, and since identity columns are typically non-null, you can insert the DataRow because that identity column would be null. The solution I provided above fixes this.
It's important to note that if you use a SqlDataAdapter to easily update a database (see SqlDataAdapter.Update(DataSet) in the .NET Framework SDK) your InsertCommand should be both an INSERT and SELECT SQL statement combined (INSERT ...; SELECT ...). This makes sure that the identity columns are updated to the correct numbers once inserted into a table (since the database may assign different numbers in a multi-user environment). If you just assign the auto-assigned numbers in your local DataSet will match those in the database, you will have problems.
You should read about ADO.NET more in the .NET Framework SDK and I suggest you try using the designers to create connections, commands, and adapters (as well as data sets as I mentioned above) and view the source code to see how it's done. Learning by example can often open the flood gates of understanding (so long as you have at least some knowledge of what's going on...which is why you should read the class and member documentation for those classes and members being used).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello
I'm working on a DirectX application, and I want it to have a configuration set window befor it works.
How can I load one form, and when it's done load the other?
thanks
|
|
|
|
|
You could just create a new form then do something like...
<br />
ConfigDialog dialog = new ConfigDialog();<br />
if (dialog.ShowDialog == DialogResult.OK)<br />
{<br />
Application.Run(new DXForm());<br />
}<br />
Make sure that your OK button sends the dialog ok message. This is the DialogResult property of the button.
|
|
|
|
|
|
somebody tell me can use IDocHostUIHandler can relize this idea,but how can do this by c#?
ok
|
|
|
|
|
IDocHostUIHandler is defined in the MsHtmHst.idl file. Basic idea is you can write your own idl file and use the midl compiler to generate the type library. Following that you can use the .NET Framework's command line tool tlbimp to generate a .NET assembly you can include within your application.
[
uuid(47F05070-FD66-45cc-AD99-74260F94A16B)
]
library WebInterop
{
import "MsHtmHst.idl";
enum tagDOCHOSTUIDBLCLK;
enum tagDOCHOSTUIFLAG;
enum tagDOCHOSTUITYPE;
interface ICustomDoc;
interface IDocHostShowUI;
interface IDocHostUIHandler;
interface IDocHostUIHandler2;
interface IHostDialogHelper;
}
Then create the type library:
midl WebInterop.idl /tlb bin\WebInterop.tlb
Then create the .NET assembly:
tlbimp bin\WebInterop.tlb /out:bin\WebInterop.dll
Now create a class that inherits from IDocHostUIHandler and of course implements the appropriate methods.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi,
I'm overloading the ++ operator for my Day Class. I have the implementation for this overload within my class and when I tested this in the debug mode, my Day which is supposed to increment as I've coded doesn't increse. It basically gives out an object of type Day itself with the next date. Here is my code. Any help with this would be appreciated. Please do help me out with this.
<br />
public static Day operator ++(Day d)<br />
<br />
{<br />
<br />
Day nxtDay;<br />
<br />
int nxtDate;<br />
<br />
<br />
try<br />
<br />
{<br />
<br />
nxtDate = d._dayofmonth + 1;<br />
<br />
nxtDate += 1 ;<br />
<br />
nxtDay = new Day(new DateTime(d.Year, d.Month, nxtDate));<br />
<br />
}<br />
<br />
catch (Exception e)<br />
<br />
{<br />
<br />
e.GetType();<br />
<br />
int nxtDayMonth = (d.Month == 12) ? 1 : d.Month + 1;<br />
<br />
int nxtDayYear = (nxtDayMonth == 1)? d.Year + 1: d.Year;<br />
<br />
nxtDay = new Day(gc.ToDateTime(nxtDayYear,nxtDayMonth,1,1,1,1,1));<br />
<br />
}<br />
<br />
return nxtDay;<br />
<br />
}<br />
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~
Shravan Addaypally
.NET Apps Developer
BellSouth Billing Inc.
Birmingham, AL 35205
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
This might seem like a dumb question, but why not use the already built-in DateTime object? Check this example out from MSDN:
<br />
System.DateTime dTime = new System.DateTime(1980, 8, 5);<br />
<br />
System.TimeSpan tSpan <br />
= new System.TimeSpan(17, 4, 2, 1); <br />
<br />
System.DateTime result = dTime + tSpan;<br />
<br />
It seems to me to get the same job done without all the hassle of making your own object.
~javier lozano
(blog || email)
|
|
|
|
|
As Javier said, just use the DateTime structure.
A few things, though: why are you just calling e.GetType without actually using it? If you don't plan on using the exception for information (and I'm betting you are just calling e.GetType to get rid of the warning about declaring a type that you don't use), then don't declare it. Simply using catch or catch (Exception) is suitable (both of those result in the same behavior).
Finally, is this a class or a struct you're using? A struct is a value type, so any changes you make to it happen on a copy - not the original object. A reference type (a class) will always be the same object, though (refers to the same object, rather). Depending on how you use your Day struct (assuming it's a struct), this could be the problem why its value appears unchanged.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
1. What is the best way to transfer a binary file over a network not using ASP and web service?
2. If I have a program that are 3 tier app have many data communication. like dataset, primitive data, binary files etc.... What is the communication protocol I should use? socket? remoting? webservice? what is their advantage and disadcantage?
Regards
Joel
|
|
|
|
|
joelwu wrote:
1. What is the best way to transfer a binary file over a network not using ASP and web service?
Whatever works for you in a given situation is best. If you use .NET Remoting (or Web Services, but you said you weren't wanting that), you could use DIME - and industry startard for efficiently sending binary data without encoding it (like base64 encoding) using SOAP, part of the Web Services Enhancements 2.0[^] for Web Services (works also with .NET Remoting with a little extra work). You could also just use a TcpClient and TcpListener (depending on whether you need to write a client, server, or both - respectively) to establish a connection and send byte[] arrays using the NetworkStream . If both are .NET clients, you can use runtime serialization (see the System.Runtime.Serialization namespace members) so long as both the client and server have access to the same types being serialized (so shared assemblies) - but this is essentially .NET Remoting so I'd recommend going with that infrastructure instead of defining your own (much more extensible, well though-out, and heavily tested).
joelwu wrote:
2. If I have a program that are 3 tier app have many data communication. like dataset, primitive data, binary files etc.... What is the communication protocol I should use? socket? remoting? webservice? what is their advantage and disadcantage?
This information is widely available on the web. I recommend doing a google search, picking up a good book (like "Advanced .NET Remoting" from Ingo Rammer[^]), or checking out some of the Microsoft resources like http://msdn.microsoft.com/webservices/[^] as well as key topics in the .NET Framework SDK[^]. Many, many articles have been written comparing the two and such a discussion would be extremely length (and redundant) in a forum such as this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This question has been asked many times and in several forums without a clear resolution.
Despite setting Basic-Auth credentials for a C# client on the service instantiated from a proxy generated using wsdl.exe, the HTTP header does not include the Authorization line.
Is there any specific configuration or permission requirement?
Thanks.
|
|
|
|
|
I need to be able to disable some things from happening while a window is being resized, i.e. while the window is being dragged with the left mouse button down, and have these things be re-enabled when the resizing is done. Does anybody know how to do this properly. I thought I could intercept the MouseDown and MouseUp events and use that to set a flag that could be read in the Resize event and used to disable stuff (and re-enable when the mouse button is released), but it seems the MouseDown and MouseUp events don't get fired when the pointer is on the border of the a window (where you grab it to drag it) instead of actually in the window.
Any ideas?
"Where do we go to get our good name back?...we go where we always go when a dramatic change is needed. We go to the ballot box" - Al Gore 5/26/04
|
|
|
|
|
The MouseDown and MouseUp events are only fired with the client area (the actual control area). They are not fired for the window frame. In order to handle these "events" (notification messages), override WndProc in your Form like so:
bool mouseDown;
const int WM_NCMBUTTONDOWN = 0x00a7;
const int WM_NCMBUTTONUP = 0x00a8;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCMBUTTONDOWN) mouseDown = true;
else if (m.Msg == WM_NCMBUTTONUP) mouseDown = false;
base.WndProc(ref m);
} Now your state variable (mouseDown ) should be assigned correctly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i wanna to use the following code to get
hte system imagelist ,but it doesn't works well,the iconCount always equal 5,and so
i can't get the correct imagelist,who can tell me what's wrong with it.
[DllImport("comctl32.dll")]
private static extern int ImageList_GetImageCount( IntPtr himl );
public static ImageList GetSystemImagelist(bool isSmall , bool isSelected )
{
SHFILEINFO info = new SHFILEINFO(true);
int cbInfo = Marshal.SizeOf(info);
SHGFI flags = SHGFI.SHGFI_SYSICONINDEX;
SHIL size ;
if(isSmall == true)
flags |= SHGFI.SHGFI_SMALLICON;
else
flags |= SHGFI.SHGFI_ICON;
if(isSelected == true)
flags |= SHGFI.SHGFI_OPENICON;
ImageList imageList = new ImageList();
IntPtr imageHandle = SHGetFileInfo("C:\\",0,out info, (uint)cbInfo,flags);
IntPtr iconHandle = IntPtr.Zero;
int iconCount = ImageList_GetImageCount(imageHandle);
for (int i = 0; i < iconCount; i++)
{
iconHandle = ImageList_GetIcon(imageHandle, i, 0);
imageList.Images.Add (Icon.FromHandle(iconHandle));
}
return imageList;
}
|
|
|
|
|
FYI, a system image list is the image list kept by the Windows shell for purposes of caching icons. What you're doing is simply getting the associated icon for a file or device.
See my previous reply to a similar thread at http://www.codeproject.com/script/comments/forums.asp?msg=585938&forumid=1649#xx585938xx[^]. This actually uses a fake filename, however. Just set the second parameter to SHGetFileInfo to 0 if you want to get the icon for a real file. This code also inserts into a large and small image list. There is absolutely no reason to P/Invoke any of the Common Control Image List APIs - they are encapsulated by the ImageList already (just as most of the Windows Forms controls encapsulate the Common Controls).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|