|
Hello Jay
this is the way I have just realized and I have also some functions to suppress keypress events, but what are you doing when there is no free field to focus to? That's all not satisfactorily !
Thanks
Some more ideas ?
|
|
|
|
|
I also agree with you. The solution is not satisfactory. I had the fix the same problem using the above solution, that is why, I posted...
BTW, If you get some different way of achieving the same. Do post the solution.
|
|
|
|
|
Hi All
I'm having a problem stated below:
I've populated a dataset from multiple tables and then bind the datagrid with this dataset. Now when the datagrid contents are changed by the user, I want to propagate these changes in the original tables. What is the most convenient way to accomplish this? I shall be very thankful for any expert advice.
Truly yours
Rashid
|
|
|
|
|
Read the SDK documentation for the DataAdapter.Update method, which describes in rather nice detail what is required and basically how it works. You use a DataAdapter -derivative - like SqlDataAdapter - with the InsertCommand , DeleteCommand , and UpdateCommand specified (in addition to the SelectCommand , which is both required and assumed since you already have a DataSet . Based on a DataRow 's DataRowState , the record will be added, updated, or deleted.
Generally you should specify an INSERT statement followed by a SELECT statement for the InsertCommand . This is because any auto-generated fields defined on the database may be different (and most likely will) than what is in your DataSet . After inserting the row, the select will make sure your DataSet contains the right data.
If you are sending this DataSet across the wire to be updated, first call DataSet.GetChanges to get a DataSet of only the changes. This is only necessary if you send the DataSet across the wire before passing it to DataAdapter (like in a typical 3-tier design). Do not call DataSet.AcceptChanges , however, otherwise all the change-tracking information is lost. DataAdapter.Update will do this upon successful completion of the update.
Read http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatacommondataadapterclassupdatetopic.asp[^] for more information.
You can also click "Search comments" above and search for "DataAdapter", for example, for previous discussions about this. We have talked about it quite a bit in this forum over the years.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
My problem is that I can't restart my remoting server. This is how I
start the server:
m_ServerSinkProvider = new BinaryServerFormatterSinkProvider();
m_ServerSinkProvider.TypeFilterLevel = TypeFilterLevel.Full;
m_Props.Clear();
m_Props.Add("port", nPort);
m_Props.Add("typeFilterLevel", TypeFilterLevel.Full);
m_TcpChannel = new TcpChannel(m_Props, null, m_ServerSinkProvider);
ChannelServices.RegisterChannel(m_TcpChannel);
RemotingServices.Marshal(InstanceOfRemoteserverClass, "DataHandler");
This is what I do when I stop the server:
RemotingServices.Disconnect(InstanceOfRemoteserverClass);
ChannelServices.UnregisterChannel(m_TcpChannel);
When I try to start the server again, I do the start part again. When
I restart, I get an exception: only one usage of each socket address
(protocol/network address/port) is normally permitted. This is caused
by:
m_TcpChannel = new TcpChannel(m_Props, null, m_ServerSinkProvider);
This exception will occur only if my client has connected atleast
once.
The reason I need to create new TcpChannel every time server is
started is that the user can decide which port the server listens. So
the user can start the server with port 9000, stop the server, change
port to 9001 and start the server again. Or it can just stop and start
the server with the same port for some reason.
So how can I design the server so that it can be started and stopped
as many time as needed? Can I change the port in the created
m_TcpChannel without creating a new instance of it everytime?
Any help will be highly appreciated.
Thank you
|
|
|
|
|
At first glance, it would seem the problem is that you're not closing the first TcpChannel . When you instantiate a new one, the first TcpChannel remains active until the GC finalizes it - assuming nothing else is referencing it. This will happen when 1) your machine is idle, 2) when memory is or is nearly exhausted, or 3) when you call GC.Collect (not a good idea since this is a synchronous (i.e., blocking) call that may take a while). Be sure to call TcpChannel.StopListening .
You actually shouldn't need to re-allocate the channel, though. IF the remoting object is not listening the channel does nothing. You would have an open port, but a port that goes no where. Just something to consider.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks a lot for helping. I added TcpChannel.StopListening, but it didn't work. The TcpChannel does remain active (as you assumed), because it is a member variable. So the old TcpChannel exists when I create a new instance of TcpChannel to the same member variable. I'm a neebie to remoting (and to also C#), so I don't really know what's going on, so the reason for the member variable is that I can use it to UnregisterChannel when I disconnect. Can I avoid using member variable and get the current tcpchannel somehow for unregistering or what should I do when I disconnect in order to be able to reconnect? Also, could I change the port in the current TcpChannel when it is not registered or listening with out creating a new instance of it?
Thanks
|
|
|
|
|
Re-instantiating it creates a new instance and assigns that instance to the field ("member variable" as you called it, which is incorrect, BTW). The old field - if nothing else references it - will be finalized (destroyed) eventually, but there's no garuantee when). Don't re-instantiate it.
Actually, you should consider using .config files to configure remoting. If you ever need to change properties, a server address, or the remoting object base location with how you're doing it now, you would have to change your code, re-compile, and test it all over again. If you use .config files the RemotingConfiguration.Configure method you get everything you did without the hastle and in a way that you can change just by editing the .config file (an XML file) and re-starting the application. If you implement two different AppDomains with one watching for changes to the file, you can take-down the other AppDomain that hosts the remoting object and re-start it. This is basically how ASP.NET works (when you edit Web.config the ASP.NET web application is reloaded, or all ASP.NET web applications are reloaded if you edit the machine.config or the virtual host's root Web.config file).
I recommend picking up a good book on Remoting, like Microsoft .NET Remoting[^] (for beginners and intermediate developers) from MS Press and/or Advanced .NET Remoting[^] from Ingo Rammer.
.NET Remoting is complex and very abstract. Either of these books can really help sort-out the details and give you ideas about how to better implement a remoting solution.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have a usercontrol with 2 basic .NET controls (one label and one textbox for example).
When i drop such a control on a form in design time, everything is fine, i can click on it anywhere to select it, resize it, etc.
But now when i try to drop a panel on the form and drag/drop my UserControl into the panel, then i can't select the UserControl anymore. Designer seems to be trying to select the inner control (the textbox or the label) but also fails. When i click on the textBox part of the usercontrol, then i can type text in, as if textbox was in runtime.
I'd have thought it would be a known issue, but i couldn't find anything about it, nor could i find a workaround. Could anyone help, please ?
Thannk you !
Etienne.
|
|
|
|
|
just check in the Form Designer Code whether the following line is present?
this.panel1.Controls.Add(this.userControl1);
where panel1 and userControl1 are the panel's name and userControl names respectively.
I tested the scenario explained by you..No problem at my end..........
|
|
|
|
|
Interesting... The issue is the same on a co-worker computer, but he has the same VS version.
I made an archive with 2 projets (Solution containing both is in Test-Bug) showing the issue.
There is a form in Test-Bug, with a panel, which contains a UserControl. Now if i select the UserControl, drag it out of the panel, parent changes and is serialized ok in InitializeComponents. (i do have the right "Controls.Add" line) But then if i de-select usercontrol, and click on the textBox again, it won't select the UserControl (cursor changes as if over a textbox, too), but the focus will go inside the textBox, allowing to type in text at design time.
Once this happened, if i quit the solution and load it back, everything is back to normal.
Thanks a lot for looking into this, i really don't understand.
Here's a link to the sample code i made :
UserControl bug ?
Etienne.
|
|
|
|
|
I do not have winRaR. that is why, I could not un-concompressed your userControl,
whereas, I re-checked the my demo userControl,
1.It does allow to write in the TextBox. But the changed text is reset after The project is being compiled.
2.It allows to select the userControl, in both the cases (user control being kept inside the panel,or outside the panel).
I am sorry, I could not minutely tested the scenario, previously....Seems to be a bug..
|
|
|
|
|
Again re-checked using UpDownControl inside an userControl. When it is dragged into the panel or dragged out of the panel. The constituent controls of the userControl starts behaving similar to the run-time.
When the project containing the userControl is being re-compiled. The problem goes.......strange.....!!!
|
|
|
|
|
Thanks a lot for taking so much time on this.
Indeed, whatever the control you have inside the UserControl is, it will begin to act as if in run-time. And all is back to normal upon recompilation or quit/reload.
Does anyone know a work-around ? any code to add to the UserControl and/or Designer ? Cause it's a pain having to re-compile so often when creating forms in design mode...
Anyway, thanks again Jay ! (look into 7-zip, it's free and handles rar files)
Etienne.
|
|
|
|
|
I found a workaround that works for me :
Override OnParentChanged in your UserControl, and for every control contained in it, remove it and add it again. You may limit this code section to DesignMode, so it won't happen at runtime.
Etienne.
|
|
|
|
|
Great.....It works...
By the way, Is this bug being already detected by the Microsoft? or being recorded by the Microsoft?
|
|
|
|
|
Hi everybody!
I've performed recording wave sound in low level (by API function) but I have a problem. In WndProc function, the MM_WIM_DATA message is occured but the buffer is not filled. Could you help me.
Thanhks
Hung
|
|
|
|
|
Read the docs about MM_WIM_DATA on MSDN: this message is also sent when waveInReset is called, so you need to check the dwFlags on the WAVEHDR structure.
Yes, even I am blogging now!
|
|
|
|
|
hi guys, I wish to find out the way to remove the whitespaces in a string
e.g "James Bond"
|
|
|
|
|
Check out the "Replace" method of the string class...
Etienne.
|
|
|
|
|
thankz for the reply, i tried using str.Replace(' ', ''); but its not possible. I need to remove all the white spaces within the string so that i can compare the string to another string.
|
|
|
|
|
string input = "How_are_you_Mr._k o b e z t 0 8? ";
input = input.Replace(" ", string.Empty);
MessageBox.Show(input);
|
|
|
|
|
tried this
string c1 = lstContent1.SelectedItem.ToString();
string c2 = lstContent2.SelectedItem.ToString();
c1 = c1.Replace(" ", string.Empty);
c2 = c2.Replace(" ", string.Empty);
System.Console.WriteLine("c1 = " + c1);
OutCome still the same
"1" "James" "Bond"
tried using c1 = c1.Replace(' ', string.Empty);
but got D:\My Documents\Visual Studio Projects\New-FYP (Try-Out) 2\Form1.cs(372): Argument '2': cannot convert from 'string' to 'char'
|
|
|
|
|
Then your "whitespaces" probably aren't spaces ( (char)32 ).
Try scanning your string characters and find out what char the "whitespace" is. Might be a \t or something. Then once you found out, you can use replace. Replace does work, and your code is right. So only thing left is that you have actually no space in your string.
Etienne.
|
|
|
|
|
string temp3 = c1[3].ToString();
string temp3a = c1[3].GetTypeCode().ToString();
System.Console.WriteLine("c1 = " + temp3);
System.Console.WriteLine("c1 = " + temp3a);
Outcome:
c1 =
c1 = Char
weird although it's stated as a char, it is a Tab in the .txt file when i check. is there any way to remove it then?
the format in the .txt file is this
"S_N" "Last_Name" "First_Name"
"1" "Yi Zhuang" "Tan"
"2" "Kai Wong" "Lei"
the file is created by exporting a access database table into a txt file
|
|
|
|
|