|
Does anyone know how i can change the color of the background of a checkbox in a tree view? The treeview is in a non-standard color and the white of the checkbox doesnt look right at all.
i read about the tri-state checkbox image but i dont think i want to take it that far at this stage.
|
|
|
|
|
Hi,
i would like to let the user edit his data in a datagrid. The datagrid is bound to a dataset. If the user close the form i would like to know:
- are there changes?
- would he like to accept or reject changes?
<p>But this do not work, cause it seems that the datagrid flush the data on dispose to the dataset, could that be ? cause HasChanges() returns false, all the time, even if i've got changes made to the Datagrid/dataset.
Is there a way to flush the changes made in datagrid to dataset, then check it, ask user and accept or reject changes ?
.:Greets from Jerry Maguire:.</p>
|
|
|
|
|
Override on closing rather
This what I did (in fact just yesterday):
<font size=2 face="Courier New"><font color="#0000FF">protected </font><font color="#000000">override </font><font color="#0000FF">void </font><font color="#000000">OnClosing</font>(<font color="#000000">CancelEventArgs e</font>)
{
<font color="#000000">DataSet ds </font>= <font color="#000000">dataSet1</font>.<font color="#000000">GetChanges</font>();
<font color="#0000FF">if </font>(<font color="#000000">ds </font>!= <font color="#000000">null</font>)
{
<font color="#000000">DialogResult result </font>= <font color="#000000">MessageBox</font>.<font color="#000000">Show</font>(<font color="#0000FF">this</font>,
<font color="#FFFFFF"> </font><font color="#FF8000">"Would you like to save " </font>+ <font color="#000000">datafile </font>+ <font color="#FF8000">" ?"</font>, <font color="#FF8000">"Confirm save file..."</font>,
<font color="#000000">MessageBoxButtons</font>.<font color="#000000">YesNoCancel</font>, <font color="#000000">MessageBoxIcon</font>.<font color="#000000">Question</font>);
<font color="#0000FF">switch </font>(<font color="#000000">result</font>)
{
<font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">Yes</font>:
<font color="#000000">SaveXml</font>(<font color="#000000">datafile</font>);
<font color="#0000FF">break</font>;
<font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">No</font>:
<font color="#0000FF">break</font>;
<font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">Cancel</font>:
<font color="#000000">e</font>.<font color="#000000">Cancel </font>= <font color="#0000FF">true</font>;
<font color="#0000FF">break</font>;
}
}
<font color="#000000">base</font>.<font color="#000000">OnClosing</font>(<font color="#000000">e</font>);
}
</font> SaveXml() is just a method I have to save the XML and datafile is a string that is the file's full path and name.
Hope this helps
[edit] I just realize its almost the same, except perhaps that you are using the event rather than overriding, and that you call GetChanges(). Never did try that How do you persist (load/save) the dataset anyways? Are you not calling AcceptChanges somewher in between, that would cause it to return false more than often. I call AcceptChanges only one after I have read the XML from a file.[/edit]
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi,
thank you, but it looks more like a workaround ,)
ok, i have to call AcceptChanges after i load the dataset from disk. These resets the interal dirty state to false. Now the user edit some values in the datagrid (HasChanges() should now return true), he close the form, OnClosing i ask him to save (checked by HasChanges), he AcceptChanges or reject changes ?
that's the way i would like to get this done. What i'm doing wrong ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (dataSet11.HasChanges())
{
switch ( MessageBox.Show("Do you wish to save your changes made for bla bla?" , "Save", MessageBoxButtons.YesNoCancel))
{
case DialogResult.Yes:
this.sqlDataAdapter1.Update(this.dataSet11);
break;
case DialogResult.No:
break;
case DialogResult.Cancel:
e.Cancel = true;
break;
}
}
}
|
|
|
|
|
Hi,
i do not use a SqlDataAdapter, the dataset is a class member. If i store the dataset to disk or to SqlDatabase, it's quite easy, cause i've i do not call a Save method, nothing happens, being updated.
Otherwise if the dataset is in a class, and the class.DataSet is bound to a datagrid, it's harder
.:Greets from Jerry Maguire:.
|
|
|
|
|
I have an XPathNodeIterator and I've been crawling through an dom tree reading in information. What I want to do is, given a node or attribute, I want an xpath expression that refers to that node.
So in other words, the opposite of XPathNavigator.Evaluate(). I want a method that takes a node and returns a string that says "/html/body/table[2]/tr[4]/td"
Is there anything built in like that? making it myself would be a pain.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Not that I know of. You can iterate backwards through the document and build
/html/body/table/tr/td
but to get the index, you'd have to iterate through the children at the same level, and try to figure out which was yours.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Hi, Coders
I have the following problem:
I am overriding a TabControl class in order to make his appearance better.
It worked just fine till I decided to implement the scrolling of the tabs - I can't get rid of the scrolling buttons windows is displaying. I tried overriding almost every virtual method and adding " Invalidate() " to it, but the scrolling buttons don't care - they still are visible
Any sugestion of how I can remove them?
Cheers,
Gogou
GAtanasov
|
|
|
|
|
There was just during the last week an article on this. Look VS.NET treeview. Get some tips from that code, or ask the author.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi, leppie
Seems to me you just haven't got my problem...
I am NOT trying to derive new tab control form user control (In the VS.NET TabControl article, if you meant this, the author did that) but rather to inherit from TabControl class.
Btw I tried to find smthing like " VS.NET treeview " but had no success
Cheers
Gogou
GAtanasov
|
|
|
|
|
In additon to displaying checked/unchecked states in a treeview, I also need to display a third state in a Windows Form to indicate a partial selection of child nodes... Something like a "/" or "X" character in the checkbox for the third state...
can someone tell me the best way to do this?
thanks.
|
|
|
|
|
I would use an image list instead of the built-in check boxes. One image for each state, and you'll need to do some interop (SendMessage(TVM_HITTEST, ...)) in order to know that the user just clicked on the image.
|
|
|
|
|
Does anyone know where I can find an example of a function which recursively searches through a directory, and its subdirectories, for all files with a certain extension, and then returns an array of FileInfo objects for each of these files?
Mark Sanders
sanderssolutions.com
|
|
|
|
|
This is my search function:
public void FindDoc(string pathfile)
{
DirectoryInfo info = new DirectoryInfo(pathfile);
foreach (FileInfo f in info.GetFiles())
{
find(f);
}
foreach (DirectoryInfo d in info.GetDirectories())
{
foreach (FileInfo f in d.GetFiles())
{
find( f );
}
FindDoc(d.FullName);
}
}
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
find(f)? where is that defined?
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
|
Sorry it has a litlle problem.It search each file tow times.Here is correct form from MSDN:
public void FindDoc(string pathfile)
{
foreach (string d in Directory.GetDirectories(pathfile))
{
foreach (string f in Directory.GetFiles(d))
{
FileInfo info = new FileInfo(f);
find(info);
}
FindDoc(d);
}
}
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Here's my final code. Rather simple really Thanks for the help.
private void GetFiles(DirectoryInfo directory, string searchPattern)
{
foreach(DirectoryInfo subdirectory in directory.GetDirectories())
GetFiles(subdirectory, searchPattern);
foreach(FileInfo file in directory.GetFiles(searchPattern))
fileList.Add(file);
}
Mark Sanders
sanderssolutions.com
|
|
|
|
|
How to validate user credentials (SSPI)on winNt, win2000,winXp, and without act as part of operating system privilege.
Example
Bool fctCheckUser(user,password,domain);
Return:
True is validate, false is not validate
I implented that but it don'work under windows xp..
[DllImport("Advapi32.dll")]
public static extern long LogonUser(string lpszUserName,string lpszDomain,string lpszPassword,long dwLogonType,long dwLogonProvider,long phToken);
const long LOGON32_PROVIDER_DEFAULT= 3;
const long LOGON32_LOGON_NETWORK= 0;
public Form1()
{
long ret = LogonUser("ll2","ww_europe","zoaqsdfzsol7",LOGON32_LOGON_NETWORK,LOGON32_PROVIDER_DEFAULT,ht);
MessageBox.Show(ret.ToString(), "test",MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
-=zoltx=-
|
|
|
|
|
The C++ DWORD type is equivalent to the .NET Int32 type, which is int in C#.
using System;
using System.Runtime.InteropServices;
public class WindowsLogon
{
public enum LogonType
{
Batch = 4,
Interactive = 2,
Network = 3,
NetworkCleartext = 8,
NewCredentials = 9,
Service = 5,
Unlock = 7,
}
public enum LogonProvider
{
Default = 0,
WinNT35 = 1,
WinNT40 = 2,
WinNT50 = 3,
}
[DllImport("Advapi32.dll")]
private static extern bool LogonUser(
string lpszUserName,
string lpszDomain,
string lpszPassword,
LogonType dwLogonType,
LogonProvider dwLogonProvider,
out IntPtr phToken);
public static IntPtr LogonUser(
string username, string password, string domain)
{
return LogonUser(username, password, domain,
LogonType.Network, LogonProvider.Default);
}
public static IntPtr LogonUser(
string username, string password, string domain,
LogonType logonType, LogonProvider provider)
{
IntPtr ret = IntPtr.Zero;
if (LogonUser(
username, domain, password,
logonType, provider, out ret))
{
return ret;
}
else
return IntPtr.Zero;
}
static void Main()
{
try
{
Console.Write("Username: ");
string user = Console.ReadLine();
Console.Write("Password: ");
string password = Console.ReadLine();
string domain = Environment.GetEnvironmentVariable("USERDOMAIN");
Console.WriteLine("Domain: {0}", domain);
IntPtr token = LogonUser(user, password, domain);
if (IntPtr.Zero == token)
Console.WriteLine("Logon failed!");
else
Console.WriteLine("Logon OK!");
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Is there any way to create UserControls in a different AppDomain of the owner form ? How can I isolate a UserControl created dynamically (for security and loading reasons)?
thanks
|
|
|
|
|
Is there any way to get a deployment project in Visual Studio.NET to give you a summary of what files it is including and, much more importantly, where it retrieved the files? I'll take anything, including VS Macros, command line, etc.
John Woodard
|
|
|
|
|
Hi guys,
Can you suggest me some ways or component to read an entire chunk of file and convert between ASCII and EBCDIC and save it back as a new file.
I got some code in fastheadcafe, but it deals with strings. But I do not know, in which format, StreamReaders or something else should be specified (Encoding Options??) so that it identifies the format and converts to the desired format.
A code example would be great!!!
Thanks and Regards,
Deepak Kumar Vasudevan
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|