|
:-OHi!
Try filling it via DataTable! or simply add rows manually.
<br />
<br />
ICollection CreateDataSource() <br />
{<br />
DataTable dt = new DataTable();<br />
DataRow dr;<br />
<br />
if(Read())<br />
{<br />
for(int i=0;i<myReader.FieldCount;i++)<br />
{<br />
dt.Columns.Add(<br />
new DataColumn(<br />
myReader.GetName(i)));<br />
}<br />
<br />
do<br />
{<br />
dr = dt.NewRow();<br />
for(int i=0;i<myReader.FieldCount;i++)<br />
{<br />
dr[i] = myReader.GetValue(i);<br />
}<br />
dt.Rows.Add(dr);<br />
}while(Read());<br />
<br />
}<br />
<br />
DataView dv = new DataView(dt);<br />
<br />
return dv;<br />
} <br />
<br />
...
dg1.DataSource = CreateDataSource();<br />
dg1.DataBind();<br />
Checkbox: try itemtemplates. Edit your aspx file.
Agyklon
|
|
|
|
|
You may to create a DataTable from array and use it as a datasource. Sorry, it isn't too smart ...
Hi,
AW
|
|
|
|
|
Thanks for the help guys
Smitha
The future belongs to those who believe in the beauty of their dreams.
--Eleanor Roosevelt
|
|
|
|
|
Create a blank project, set the WindowState to minimized in the designer and in the form1_load event put this.Hide();
Now why do I get different behavior when I keep the WindowState to Normal but add this.WindowState = FormWindowState.Minimized; this.Hide();
to the form1_load event?
Aren't they the same thing?
|
|
|
|
|
I have created a MDI parent form which has a UserControl
inside.
I create two instances of the form with the UserControl as
mdi children.
I shrink them down vertically so scroll bars appear. Then
drag the scrollbars down to the bottom of the form.
Select one child form, and then select another child form,
in effect, changing focus between the two forms.
When I click on one child, then another, the contained
UserControl jumps and the scroll bar moves to reposition
the contents of the form.
I do not see this behavior if I use a label instead of a
user control.
I dont want the contents of the child form to be
repositioned when you change focus to/from a child.
Having this behavior really breaks my app; I cannot have
windows automatically moving contents after a user has
carefully positioned the windows and the scroll bars where
they want them.
How can I keep the contents of a form with a UserControl
in the same place even if the user moves around between
different MDI child windows?
I saw mention of a known bug in .NET that was described as
follows from the following link:
http://www.windowsforms.com/Forums/showpost.aspx?
tabindex=1&tabid=41&PostID=261
Case in point, killing that annoying autoscroll reset to
upper left corner on a scrollable control recieving focus.
Took me about 8 hours to work around it; the simple
override of WndProc to ignore WM_SETFOCUS seemed OK at
first, but screwed up the setting of the active control
property. If I had access to source, it would have taken
me all of 5 minutes to find the proper workaround (setting
the scroll state to manual during the WM_SETFOCUS handler)-
-
Can anyone suggest what is going on here, and perhaps give
me a start on how to fix the problem? I am not familiar
with overriding Wndproc.
|
|
|
|
|
I need to copy and send the data in a private structure from an MFC app to a .NET app. Somehow, the following does not seem to work. When I use the WM_COPYDATA windows message as indicated below, it is not being received by the WndProc on the .NET side, but when I use a private message, it is received. Unfortunately, when I use the private message, the data seems not to be copied across and I get an assertion error for null data. WM_COPY is not received on the .NET side, but when a private message is used, it is received but then Marshal.PtrToStructure asserts reporting a null value.
Using COM interop is not an option. The client thinks that COM will slow things down as the function is called thousands of times.
Does any one have a suggestion, or a better approach?
Thanks
Gaul
****************************
ON THE MFC SIDE
****************************
////////////////////////////////////////////////////////////
// Increment is called on the MFC side
/////////////////////////////////////////Increment Counter
long CTSPerfMon::Increment(int objectID, int instID)
{
_msg.nMsgID = TS_MSG_INCREMENT;
_msg.nObjectID = objectID;
_msg.nInstID = instID;
_msg.nValue = -1;
return SendMessage();
}
// Send Message across to the .NET side module
long CTSPerfMon::SendMessage()
{
// Fill the WIN32 COPYDATASTRUCT structure
_copyData.dwData = _nPerfMsg; // Message identifier
_copyData.cbData = sizeof(_msg); // size of data
_copyData.lpData = &_msg; // data structure
// Call function, passing data in &_msg
long nRetCode = -1;
if ( _hPerfWnd != NULL )
{
HWND hWnd = GetForegroundWindow();
if (hWnd == NULL)
hWnd = GetDesktopWindow();
nRetCode = ::SendMessage( _hPerfWnd,
WM_COPYDATA, //private message works here
(WPARAM)(HWND) hWnd, //windows sending the data
(LPARAM)(LPVOID) &_msg);
}
return nRetCode;
}
****************************
ON THE C# .NET SIDE
****************************
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == (int) Msgs.WM_COPYDATA)
{
COPYDATASTRUCT copyData = (COPYDATASTRUCT) Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
if ((object) copyData != null)
{
IntPtr nPerfMsg = copyData.dwData;
if (nPerfMsg.ToInt32() == _nPerfMsg)
{
TSMSG msg = (TSMSG) Marshal.PtrToStructure(copyData.lpData, typeof(TSMSG));
int nRetCode = ProcessMessage(ref msg);
m.Result = (IntPtr) nRetCode;
return;
}
}
}
base.WndProc(ref m);
}
Structure definition on the MFC C++ side
----------------------------------------
#ifdef __cplusplus
extern "C" { // Assume C declarations for C++
#endif
typedef struct tagTSMSG
{
int nMsgID;
int nObjectID;
int nValue;
int nInstID;
}TSMSG;
#ifdef __cplusplus
} // End of extern "C" {
#endif // __cplusplus
Structure definitions on the .NET side:
--------------------------------------
[StructLayout(LayoutKind.Sequential)]
public struct TSMSG
{
public int nMsgID;
public int nObjectID;
public int nValue;
public int nInstID;
}
[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
public IntPtr dwData;
public int cbData;
public IntPtr lpData;
}
Gaulles
|
|
|
|
|
I have a treeview/listview combo I’m using as a mechanism to select folders and files to become the contents of a “backup job” file. Every entry in the treeview and listview has a checkbox next to it for selection.
This job file will be used by a windows service that will wake up, read the job file and copy folder/files to another mapped drive according to the contents of the job file….
I need to build some sort of string array or linked list that can grow/shrink dynamically, that mirrors the user’s selections… so every time the user checks a checkbox for a given selection, the path string is added to the string array/linked list, and removed when the box is unchecked… then when the user clicks “create jobfile”, the array/linked list is written out to a file.
Is a linked list the best way to go here, or is there a better choice using the .NET framework?
thanks.
|
|
|
|
|
I found this artical and it's been a great help. Only thing is I need to set dWord values greater than 2,147,483,647! I am sure that somebody has found a way around this.
Here is my code:
RegistryKey regKey = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Services\nsunicast\Parameters\Virtual Roots\/"+eId);
regKey.SetValue("MaxBandwidth", 4294967295); // if I change this to below the number above it will set as a dWord all day long.
Any examples, or ideas would rock.
Thanks,
Bill K.
|
|
|
|
|
DWORD = UInt32; //all day long (what ever you meant be that)
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
leppie wrote:
DWORD = UInt32;
I am not exactly sure how to use that?
I did try this and I got no compile errors. I did however still get a string in the reg and not a dword as desired?
UInt32 maxValue = 4294967295;
regKey.SetValue("MaxBandwidth", maxValue);
Thanks,
Bill K.
|
|
|
|
|
codeweenie wrote:
I did however still get a string in the reg and not a dword as desired?
I don't think you can create anything else using the .NET Registry handlers.
Either use Interop to get at the API registry functions or convert to and from a string using SetValue.
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
Paul Riley wrote:
Either use Interop to get at the API registry functions or convert to and from a string using SetValue.
Can you show me an example? I am not following you. Thing is the value that I am writing into the registry is a value that Windows Media Streaming server needs. This is not for a program of my own. I am trying to automate some stuff so converting it to or from a string is not really the answer, I don't think. I am able to feed the value in as a dword value as long as I keep it below that 2147483647 number and do it like this:
regKey.SetValue("MaxBandwidth", 2147483647);
However if I try to do this, the number gets converted to a string:
regKey.SetValue("MaxBandwidth", 4294967295);
So then I tried this:
UInt32 maxValue = 4294967295;
regKey.SetValue("MaxBandwidth", maxValue);
This also gets converted to a string.
Thanks,
Bill K.
|
|
|
|
|
codeweenie wrote:
This is not for a program of my own. I am trying to automate some stuff so converting it to or from a string is not really the answer, I don't think.
You are correct, so you need to use Interop.
This is slightly complicated at first but once you get the hang of it, it's quite easy (that's the story of everything .NET, in my experience). This[^] is a fair introduction to Interop. Other than that, you can search for DllImport/DllImportAttribute here and on MSDN and find more detailed examples.
Once you understand that, it's just a case of looking up the API registry calls: RegOpenKeyEx and RegSetValueEx.
If you run into any more problems, come back and ask.
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
Try this perhaps:
UInt32 maxValue = 4294967295;
regKey.SetValue("MaxBandwidth", maxValue.ToString("X")); //???
or maybe add a byte[], I cant really see what you can do from the docs.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
leppie wrote:
regKey.SetValue("MaxBandwidth", maxValue.ToString("X")); //???
I tried this, and I get "FFFFFFFF" as my value in the reg. It's a string value of course. Not sure how to employ the byte[] stuff.
From the docs and what I can't find on MSDN's site, I agree, this is getting to be a real problem. I can't understand why M$ would have one of their servers expect a value that can't be set via another program, that just does not make sense to me. There has to be a way to set this. I can't believe that somebody has not created a work around for it. I am just to new to C# to know how to do it just yet.
Thanks,
Bill K.
|
|
|
|
|
Someone help me out!
On my old VB Application, I use
set fvapp = createobject("fldview.application")
to create the ole automation server, work on it and use
set fvapp = nothing
to close the server. It works perfect.
when I convert to C#, since there is no way to free the fvapp, the server will be keep runing until my VB app close.
How I force C# to close the external OLE server? using "fv = null" doesn't work.
it close the server's interface, but the exe file is running still in the task list.
|
|
|
|
|
Try Marshal.ReleaseComObject()
|
|
|
|
|
A lot of exe COM servers expose a fvapp.Quit method.
If that's not enough, try sending the WM_QUIT message.
|
|
|
|
|
I need to construct a C# project that is a winform client and displaying an HTML stream within a control on that form. I have a need to be able to stream an HTML document to the control, including some DHTML, capture click events and context menu events.
Has anyone done something like this? I am aware of syncFusion FAQ but their article and examples are a bit flaky (displaying the form crashes and finding how they are passing the text to populate the example is deeply hidden within the code) and don't really answer my question.
I'm pretty sure I will have to construct my own control but don't even know where to begin. Any suggestions or help would be greatly appreciated.
MJ
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing. -Einstein
|
|
|
|
|
Take a look at my article MaChat[^]. Unfortunately, it's written in MC++.
However, I've got some code in C# which does what you probably need ( WebBrowserEx & DHTMLControl ). If you want it send me your e-mail address.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
Hi,
Im writing an application, that connects to multiple http servers by using threads.
I spawn about 30 threads and they uses httprequest and httpresponse.
I dont use any callback, cause i have done some simple que syncs.
(using lock)
Each thread loops to different sites.
Its Act a little like a crawler, with reg exp to stript some links etc.
My problem is when I have ran the app. for a couple of minutes and I get this error. (I cant catch it)
SystemOutOfMemory
mscorlib.dll!System.Threading.Overlapped::unpack(System.Threading.NativeOverlapped* nativeoverlapptr = {System.Threading.NativeOverlapped})
I cant debug it, but Im thinking mayby its the httprequest ?
Does anyone have problems with httprequest?
Or do anybody know how I can find the problem.. (some kind og debugging tips etc)?
Or know how I can supress the error msg
Regards
|
|
|
|
|
There is a very good example at GotDotNet. Search for WebSpider, excellent code. He implemented his own threadpool, which you should be doing (I think the max is 30 threads???). You can just modify that.
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,
Thanks once again for the help! I will certainly look into that.
It's looks VERY interesting.
But I have already done alot of coding making the que, classes etc.
All is done by using my current threading method
But mayby its the solution..
But thanks again leppie!
Regards
|
|
|
|
|
If you are looking to track down the bug I'd recommend the allocation profiler which will give you memory snapshots (same site) and compuware's devpartner profiler might give you some insight.
|
|
|
|
|
I am looking for a way of converting a System.Type to a System.Data.SqlDbType
So when I write a type as text it gets the right SqlDbType.
for instance let's say I've got a variable a of an unknown type,
with function GetType() I can get the System.Type of a.
Now i'm looking for a way to do the same and get the right SqlDbType
of the same variable.
Any thoughts?
|
|
|
|