|
Why I personally perfer having the second form just return the data as a property or something, passing a reference to the first form isn't hard at all. Here's an example:
public class FirstForm : Form
{
private void btnSecondForm_Click(object sender, EventArgs e)
{
using (SecondForm form = new SecondForm(this))
{
form.ShowDialog(this);
}
}
internal ListView TheListView
{
get { return theListView; }
}
}
internal class SecondForm : Form
{
private FirstForm parent;
public SecondForm(FirstForm parent)
{
this.parent = parent;
}
private void btnOK_Click(object sender, EventArgs e)
{
ListView view = parent.TheListView;
if (view != null)
{
this.DialogResult = DialogResult.OK;
}
}
} As you can see, though, not SecondForm is tightly coupled with FirstForm , which is why simply having the SecondForm define a property which returns the input data would be better, because then you could use it anywhere when you need to query for such data.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
Can someone pls tell me, if its possible to change the permissions of a registrykey using C#.
Searching the web, all I found is to read/create/write... keys and values, but the often asked question to give a userthe right to read/execute is never answerd.
(to be more specific: I used aspnet_setreg.exe to create registrykeys. In my Web.config I use the identity-tag. The only way to give the ASPNET Machine Account the right to read the keys I found is using regedit / Context-Menü and add the account manually)
thx for replies
Sebastian
|
|
|
|
|
Yes, it is possible, but you must P/Invoke a lot of native APIs in order to do so. It's definitely not an easy task. If this isn't something you need to do often or automate, don't bother.
If you need to, see the RegSetKeySecurity API in the Platform SDK on MSDN[^]. There's also examples available that use this and related APIs. You'll need to P/Invoke all these methods, as well as declare all the structs and consts necessary to set security on registry keys.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you for the reply. I feared a solution like this, but now I know which way to go.
Sebastian
|
|
|
|
|
Hello,
I have a simple xml-file and i show it in a datagrid like this:
ds.ReadXml(@"c:\nodes.xml");
But one of the colums is true/false. So i would like a column with checkboxes in my datagrid. I found something about the DataGridBoolColumn but i can't make it work. Is it possible or is their another way?
thx in advance.
|
|
|
|
|
Why can't you make it work? Please be specific.
All you need to do is add it to your DataGrid<code> and bind it to your column by setting the <codE>MappingName as you would with a DataGridTextBoxColumn .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'll try to explain it.
ds.ReadXml(@"c:\testnodes.xml");
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "library";
GridColumnStylesCollection myGridColumnCol;
myGridColumnCol = dataGrid1.TableStyles[0].GridColumnStyles;
// Get the CurrencyManager for the table.
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[ds.Tables["library"]];
/* Get the PropertyDescriptor for the DataColumn of the new column.
The column should contain a Boolean value. */
PropertyDescriptor pd = myCurrencyManager.
GetItemProperties()["super"];
DataGridColumnStyle myColumn = new DataGridBoolColumn(pd);
myColumn.MappingName = "super";
myGridColumnCol.Add(myColumn);
this is code i found on the internet, in the datagrid i can see the data but just text, no column has checkboxes.
the xml-file looks like this:
<sessie name="bedrijf">
<libraries>
<library name="comlib">
<fullname>comlib.p</fullname>
<super>true</super>
<loadorder>4</loadorder>
</library>
<library name="templateinqlib">
<fullname>templateinqlib.p</fullname>
<super>true</super>
<loadorder>5</loadorder>
</library>
<library name="Librarytest">
<fullname>Test</fullname>
<super>false</super>
<loadorder>5</loadorder>
</library>
</sessie>
thx in advance
|
|
|
|
|
That's a bad example if I ever saw one. First, they don't set a DataGridTableStyle.MappingName so that the table style would never be used. Second, you just manually add your DataGridColumnStyle s to the table style you set up. If you use a typed DataSet , VS.NET has great designers to help you bind against it, though it's not hard to do anyway. This is most likely why you're not seeing your DataGridBoolColumn - because the table style isn't even being used.
Read the documentation for the DataGridTableStyle class, which includes more information and an example.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thx for helping me and is was indeed a bad example
ds.ReadXml(@"c:\testnodes.xml");<br />
dataGrid1.DataSource = ds;<br />
dataGrid1.DataMember = "library";<br />
<br />
DataGridTableStyle ts1 = new DataGridTableStyle();<br />
ts1.MappingName = "library";<br />
DataGridColumnStyle Col = new DataGridTextBoxColumn();<br />
Col.MappingName = "fullname";<br />
Col.HeaderText = "IsCurrent Customer";<br />
Col.Width = 150;<br />
ts1.GridColumnStyles.Add(Col);<br />
<br />
DataGridColumnStyle boolCol = new DataGridBoolColumn();<br />
boolCol.MappingName = "super";<br />
boolCol.HeaderText = "IsCurrent Customer";<br />
boolCol.Width = 150;<br />
ts1.GridColumnStyles.Add(boolCol);<br />
<br />
DataGridColumnStyle TextCol = new DataGridTextBoxColumn();<br />
TextCol.MappingName = "loadorder";<br />
TextCol.HeaderText = "Customer Name";<br />
TextCol.Width = 250;<br />
ts1.GridColumnStyles.Add(TextCol);<br />
<br />
dataGrid1.TableStyles.Add(ts1);
i followed your advice and tried it on my application and it worked. But i'm still forgetting something. I can see checkboxes in my datagrid now but they are all checked (in grey) although in my xml-file some are false. I can click them but they change back immediately when i leave a cell which is not good because when it's changed it has to change in the xml-file too.
hope you understand what i mean and thx again
|
|
|
|
|
Don't declare your variables as the base class (i.e., DataGridColumnStyle ) so that you can easily access the FalseValue and TrueValue properties and set them accordingly. You can still just pass those variables into GridColumnStyles.Add because they are still DataGridColumnStyle instances (since it's their base class).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i'm sorry but i don't really understand what you mean? Don't i have to declare the variables?
|
|
|
|
|
Yes, but don't declare them as DataGridColumnStyle otherwise you have to cast them to access the properties. Just declare them as the types you're instantiating:
DataGridBoolColumn col1 = new DataGridBoolColumn();
DataGridTextBoxColumn col2 = new DataGridTextBoxColumn();
tableStyle.GridColumnStyles.Add(col1);
tableStyle.GridColumnStyles.Add(col2);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
oh ok i understand. I also found an example of it in the MSDN, i do exactly the same and the name of my table and column are correct too.
He says there is a mistake in this line
boolCol = (DataGridBoolColumn) dataGrid.TableStyles["library"].GridColumnStyles["super"];
:
An unhandled exception of type 'System.NullReferenceException' occurred in Test.exe
Additional information: Object reference not set to an instance of an object.
Do you know what could be wrong?
DataGridBoolColumn boolCol = new DataGridBoolColumn();
boolCol = (DataGridBoolColumn) dataGrid.TableStyles["library"].GridColumnStyles["super"];
boolCol.MappingName = "super";
boolCol.TrueValue = true;
boolCol.FalseValue = false;
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
|
|
|
|
|
Yeah, you can't reference a column before it's added to the table style! Remove the second line in your code sample. I don't know why you added it in the first place. You're already instantiating boolCol , so why are you (incorrectly) trying to get it then from the table styles - which you haven't added the column to yet?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i made a little mistake while typing, it had to be :
DataGridBoolColumn boolCol; and not " = new DataGridBoolColumn "
boolCol = (DataGridBoolColumn) dataGrid.TableStyles["library"].GridColumnStyles["super"];
boolCol.MappingName = "super";
boolCol.TrueValue = true;
boolCol.FalseValue = false;
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
But if i remove the second line as you said it still doesn't work
then it's the same as it was before, de checkboxes are grey and you can't change them.
|
|
|
|
|
Again, you can't reference the column until it's actually added. You want DataGridBoolColumn boolCol = new DataGridBoolColumn(); .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok thx a lot!
another problem i just encountered was
boolCol.TrueValue = true;
should be:
boolCol.TrueValue = "true";
so now he does change the checkboxes
|
|
|
|
|
Of course, because both TrueValue and FalseValue (which you should also set) are string properties.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yep i did that, it was just confusing because in the MSDN stood true and false and not "true" and "false"
but that might be different whether you are working with xml or not
|
|
|
|
|
They don't quote the strings because it's supposed to be obvious since the property type is a String .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi
i dont know how to subtract the 3 d[][][]
matrix and i want to know how to demonstrate the project
help me in matrix projects
|
|
|
|
|
Hi,
I had a big flickering problem. This is now partially solved. There's a big panel where the user can draw a rectangle while pressing the shift button. Until today everytime when the mouse was moved, I was redrawing the whole panel. This is not necessary. So now I only invalidate the 'old' rectangle (after moving the mouse). This is already much better. But when the user draws a very big rectangle, I get more and more flickering...
So here is my question: Is there an easy way to invalidate only the borders of the rectangle (so without it's interior). After I did this, I could draw the new rectangle... Or do I have to invalidate the 4 borders of the rectangle seperately?
Thanks...
TweeZz.
|
|
|
|
|
you could do that. invalidate using four rect, and these each rect invalidate onle one edge of rect. Its a cake to implement.
let me know if you have any other issue.
Shail Srivastav
shailsrivastav@hotmail.com
|
|
|
|
|
Hello,
I'm a kindof newbie to SOAP, so please help me with this problem. It could be a very basic one, but I'm trying to figure out what's wrong in this, since a couple of days now! The webservice runs fine when invoked from IE, but from my app, it doesn't receive the parameter.
Here's my setup information & code segments to help you help me:
* Server End:
Windows Server 2003 Enterprise Edition, IIS 6.0, VS.NET 2003
* Web Service:
The C# web service is just supposed to receive a string and return a string.
Code Segment:
[WebMethod (CacheDuration = 30)]
public string GreetMe(string sName)
{
return ("Hello " + sName + "!");
}
* At the Client End:
VC++ (MFC) - Using MS-SOAP Toolkit 3.0
I am not using a WSDL file, and I am directly trying to invoke the
Web Service.
Code:
void CSOAPClientDlg::OnBtnGetString() {
try
{
ISoapConnectorPtr psmConnector = NULL;
ISoapSerializerPtr psmSerializer = NULL;
ISoapReaderPtr psmReader = NULL;
CString csName;
psmConnector.CreateInstance(__uuidof(HttpConnector30));
psmConnector->Property["EndPointURL" = "http://172.16.1.95/WebServices/ws1/Service1.asmx";
psmConnector->Connect();
psmConnector->Property["SoapAction"] = "http://172.16.1.95/WebServices/ws1/GreetMe";
psmConnector->BeginMessage();
psmSerializer.CreateInstance(__uuidof(SoapSerializer30));
psmSerializer->Init(_variant_t((IUnknown *) psmConnector->InputStream));
psmSerializer->StartEnvelope("", "STANDARD", "");
psmSerializer->StartBody("STANDARD");
psmSerializer->StartElement("GreetMe", "http://172.16.1.95/WebServices/ws1/", "", "");
psmSerializer->StartElemen("sName", "", "STANDARD", "");
GetDlgItem(IDC_TXT_GREET)->GetWindowText(csName);
psmSerializer->WriteString(csName.AllocSysString());
psmSerializer->EndElement();
psmSerializer->EndElement();
psmSerializer->EndBody();
psmSerializer->EndEnvelope();
psmConnector->EndMessage();
psmReader.CreateInstance(__uuidof(SoapReader30));
psmReader->Load(_variant_t((IUnknown *) psmConnector->OutputStream), "");
GetDlgItem(IDC_TXT_XML)->SetWindowText((const char *)psmReader->RpcResult->xml);
GetDlgItem(IDC_TXT_GREET)->SetWindowText((const char *) psmReader->RpcResult->text);
psmConnector.Release();
psmSerializer.Release();
psmReader.Release();
psmSerializer = NULL;
psmReader = NULL;
psmConnector = NULL;
}
catch(...)
{
AfxMessageBox("Something Wrong! - 1");
}
}
* Problem:
When I provide the "String" in the dialog, the function above sends it in a SOAP request to my server (172.16.1.95). But the response from the server is just "Hello !" - Without the string that was sent to the server.
* On capturing the packet being sent, I have the following SOAP Request being sent to the server (172.16.1.95) on
my local network:
-----------
POST /WebServices/ws1/Service1.asmx HTTP/1.1
SOAPAction: "http://172.16.1.95/WebServices/ws1/GreetMe"
Content-Type: text/xml; charset="UTF-8"
User-Agent: SOAP Toolkit 3.0
Host: 172.16.1.95
Content-Length: 776
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema"
xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAPSDK4:GreetMe
xmlns:SOAPSDK4="http://172.16.1.95/WebServices/ws1/" SOAP-
ENV:encodingStyle="">
<SOAPSDK5:sName
xmlns:SOAPSDK5="http://172.16.1.95/WebServices/ws1/GreetMe" SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">Nirav</S
OAPSDK5:sName>
</SOAPSDK4:GreetMe>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
-----------
The "sName" parameter being sent in the message is not being received at the webservice end at all. Hence the reply message is without the "sName" value.
Thanks, in advance!
Rgds,
Nirav
* Don't wish it was easier, wish you were better! *
|
|
|
|
|
Server side seems OK. You'd get better reply in VC forum. Have you tried to find any sample in internet which consume web service from VC6 with Soap Toolkit? I've used it in VB6 and it doesn't bother at all.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|