 |
|
 |
Hi the article is great but still its not giving a clear idea.
can u pls be more specific in self-Joined section
Cheers
Bino
www.codepal.co.in
|
|
|
|
 |
|
 |
why didnt i find this yesterday?
very neatly done, thanks!
|
|
|
|
 |
|
 |
Thanks buddy,
It has saved my a lot of time.
|
|
|
|
 |
|
 |
Vishal Jani
|
|
|
|
 |
|
 |
How do you DoDragDrop such that only cities can be dropped on cities and states can only be dropped on states, and so forth?
|
|
|
|
 |
|
 |
Just wanted to say thanks! I was surfin' looking for a solution like this. It needed a little tweakin (I use guids rather than ints, etc.), but it worked like a charm! -d
|
|
|
|
 |
|
 |
This piece of code is in the treeview1_dragdrop event. I am removing the old node and inserting the dropped node in the new structure. Then I am deleting the dragged node from the underlying view. How do I update the dataset and subsequently the database from the dvwData dataview? The dataset dataSet11 does not recognize that I have deleted the dataview dvwData row.
thanks
TreeNode DragNode = new TreeNode(s);
DropNode.Parent.Nodes.Remove(this.NodeToBeDeleted);
DropNode.Nodes.Insert(DropNode.Index+1, DragNode);
dvwData.Delete(this.NodeToBeDeleted.Index);
try
{
DataSet changedData = dataSet11.GetChanges();
if (changedData != null)
{
int numRows = this.oracleDataAdapter1.Update(dataSet11);
MessageBox.Show("Database updated " + numRows + " rows successfully", "Success");
dataSet11.AcceptChanges();
}
else
{
MessageBox.Show("Nothing to save", "No changes");
}
}
catch(Exception ex)
{
MessageBox.Show("An error occurred updating the database: " + ex.Message,"Error", MessageBoxButtons.OK,MessageBoxIcon.Error);
dataSet11.RejectChanges();
}
Ram
|
|
|
|
 |
|
 |
Hi
it is nice project but how about treeview in webform?
(private)r u iranian?;)
Emad
|
|
|
|
 |
|
 |
I am supposed to populate a windows forms treeview control using c# language from a data source which is a relational table (oracle table) without using xml. Is it possible to do this and how do we do it?
Thanks for the answer.
Ram
|
|
|
|
 |
|
 |
Of cource it is possible! You have to define a parent chind relationship in you table. for example
(Also check the recusrive code in the example)
<font size=-2>
+--------+----------+----------------+
| ItemID | ParentID | Caption |
+--------+----------+----------------+
| 1 | 0 | Item 1 |
+--------+----------+----------------+
| 2 | 1 | Item 1.1 |
+--------+----------+----------------+
| 3 | 1 | Item 1.2 |
+--------+----------+----------------+
| 4 | 0 | Item 2 |
+--------+----------+----------------+
| 5 | 4 | Item 2.1 |
+--------+----------+----------------+
+-- Item 1
| |
| +------ Item 1.1
| |
| +------ Item 1.2
|
+-- Item 2
|
+------ Item 2.1
</font>
C:\>csc *.cs
Microsoft (R) Visual C# .NET Compiler
error CS2001: Source file 'brains.cs' could not be found
fatal error CS2008: No [brains.cs] specified
C:\>
|
|
|
|
 |
|
 |
Thanks for the information gevik. I am sorry, I am new to c#. Could you please give me more information on how to do this? Could you give me a sample code or lead me to some site where somebody does this?
thanks for your help?
Ram
|
|
|
|
 |
|
 |
Nice article.
I tried to add a country node and a few cities in the table treeview of tree-data.xml. The data added to the xml document but I don't see the data in the tree at runtime. I know the data is loading ( and not the dummy data) because the console shows "file exists" at runtime. I added the nodes as follows:
17 1 United States
18 17 New York
19 17 Reno
20 17 Denver
is there something wrong with the way I added the data
Thanks
don
edit Okay, I see .
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
 |
|
 |
hi there,
you cah have your data related to the node in one object and add that object to the Tag property of node.
|
|
|
|
 |
|
 |
Hi!
Stack using is not a good choose for such kind of operations.
What will be with application if you want to work with 10000 items, 1e-6, 1e-8....
Better to use Stack collection for such work... Heap is more useful place for such work.
Recursion is not a good solution for big array, but for small is fast and correct.
Good Luck
Alex Kucherenko
|
|
|
|
 |
|
 |
Would you please explain how to use heap insted of stack.
Thanx
C:\>csc *.cs
Microsoft (R) Visual C# .NET Compiler
error CS2001: Source file 'brains.cs' could not be found
fatal error CS2008: No [brains.cs] specified
C:\>
|
|
|
|
 |
|
 |
Try to modify code in such case:
- do not call function in recursion
- use Sustem.Collections.Stack class
- Stack methods Push and Pop can be used as a analog of recursion
When recursion end condition is true then Stack.Pop(...) methos must be called, otherwise call Stack.Push(...) method. By such method calls you can emulate function recursion...
Sorry but i have not too much time to show this in example...
But I have example which use STL Stack() class, maybe this can make my suggestions more effective and understandable:
//////////////////////////////////////////////////////////////////////////
// Function creater threaad and start find process ...
HANDLE CFindFile::FindFiles( void )
{
DWORD tid = 0;
m_dwError = 0;
m_stackPath.push( new CDirectoryStore( m_strStartPoint ) );
m_hThread = ::CreateThread( NULL, 0,
( LPTHREAD_START_ROUTINE )FindDirFileThread, ( LPVOID )this,
CREATE_SUSPENDED, &tid );
if( m_hThread == NULL )
m_dwError = GetLastError();
else
{
if( ::SetThreadPriority( m_hThread, THREAD_PRIORITY_HIGHEST ) == 0 )
m_dwError = GetLastError();
if( ::ResumeThread( m_hThread ) < 0 )
m_dwError = GetLastError();
}
return m_hThread;
};
//////////////////////////////////////////////////////////////////////////
//
DWORD CFindFile::FindDirFileThread( CFindFile *pThis )
{
if( pThis->m_stackPath.size() == 0 )
ExitThread( 0 );
CFuncLog log( pThis->m_pLog, "CFindFile::FindDirFileThread" );
WIN32_FIND_DATA tFind;
string tmpPath;
HANDLE hFind = NULL;
char ext[_MAX_EXT];
string tmpExt = "." + pThis->m_strExt;
while( pThis->m_stackPath.size() > 0 )
{
std::auto_ptr< CDirectoryStore > pDir( pThis->m_stackPath.front() );
tmpPath = pDir->GetRoot() + "\\*";
log.LogString( LOG_INFO, "Current Root: " + pDir->GetRoot() + "\n" );
// NOTE: -- here we skip first directory - because it's always must
// be equel to '.' directory --
hFind = ::FindFirstFile( tmpPath.c_str(), &tFind );
if( hFind == INVALID_HANDLE_VALUE )
{
PSHARE_INFO_502 BufPtr = NULL, p;
NET_API_STATUS res;
LPTSTR lpszServer = NULL;
DWORD er=0, tr=0, resume=0;
_bstr_t path( pDir->GetRoot().c_str() );
res = ::NetShareEnum( path, 502, (LPBYTE *) &BufPtr, -1, &er, &tr, &resume);
if( res == ERROR_SUCCESS || res == ERROR_MORE_DATA )
{
p = BufPtr;
for( int j=0; j < er; j++ )
{
//if( ::IsValidSecurityDescriptor( p->shi502_security_descriptor ) != 0 )
//{
_bstr_t netname( p->shi502_netname );
UINT lLen = netname.length();
// Skip hidden shares
if( ( ( char * )netname )[ lLen-1 ] != '$' )
{
pThis->m_stackPath.push(
new CDirectoryStore( pDir->GetRoot() + "\\" + string( netname ) ) );
log << "Network Share Folder:" << _bstr_t( p->shi502_netname );
}
//}
p++;
}
::NetApiBufferFree( BufPtr );
}
else
{
pThis->m_stackPath.pop();
continue;
}
}
while( 1 )
{
if( ( tFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) > 0 )
{
if( strcmp( tFind.cFileName, "." ) != 0 && strcmp( tFind.cFileName, ".." ) != 0 )
{
pThis->m_stackPath.push(
new CDirectoryStore( pDir->GetRoot() + "\\" + string( tFind.cFileName ) ) );
}
}
else
{
_splitpath( tFind.cFileName, NULL, NULL, NULL, ext );
if( stricmp( ext, tmpExt.c_str() ) == 0 )
pDir->AddFile( tFind.cFileName );
}
if( FindNextFile( hFind, &tFind ) == FALSE ) break;
}
if( pDir->size() > 0 )
pThis->m_listFiles.push_back( pDir.release() );
pThis->m_stackPath.pop();
FindClose( hFind );
hFind = NULL;
}
return 0;
};
Sorry for not very clear example, it just a code which I use in Fast File Find algorithm
Alex Kucherenko
|
|
|
|
 |
|
 |
Here is an working example of the CreateNodesOfParent() function, rewritten using Stack Class
public void CreateNodesOfParent() {
System.Collections.Stack stack = new System.Collections.Stack();
stack.Push(new object[]{0,(TreeNode)null});
while (stack.Count > 0) {
object[] obj = (object[])stack.Pop();
int iParent = (int)obj[0];
TreeNode pNode = (TreeNode)obj[1];
DataView dvwData = new DataView(sdsData.Tables[0]);
dvwData.RowFilter = "[PARENT] = " + iParent;
foreach(DataRowView Row in dvwData)
{
if(pNode == null) {
TreeNode zNode = this.Nodes.Add(Row["Caption"].ToString());
stack.Push(new object[]{Int32.Parse(Row["ID"].ToString()),zNode});
}
else {
TreeNode zNode = pNode.Nodes.Add(Row["Caption"].ToString());
stack.Push(new object[]{Int32.Parse(Row["ID"].ToString()),zNode});
}
}
}
}
|
|
|
|
 |