|
Thanks I was also looking for this.
|
|
|
|
|
That looks like its worth a shot.
I guess, if text on a button spans 2 lines, I need to get the "size" of the button's print area.
That may be different than the size of the button right?
Maybe there is a "client area size" property or something ...
In any case, that call starts me off.
Thanks,
-Luther
|
|
|
|
|
Ok - I know this is a naive question, but where do I get a graphics object.
I am not in an event handler. I am in my custom control's constructor. Its not attached to anything. I just create a button and I've set the Text property, and now I want to set the Size property.
It seems that I can't create an instance of the graphics object ... and this is not a static method.
I'm not a GDI+ expert but I would guess that I can't just create a Graphics object because there is more to the drawing context that must be defined. Where am I drawing? Which window are we drawing to, etc. Maybe I can must measure the string size in the OnPaint handler (using the parameterized graphics object).
Thanks,
-Luther
|
|
|
|
|
Is there a switch to disallow manual text entry into a ComboBox?
Or do I need to catch the KeyPress event and impl this myself?
-Luther
|
|
|
|
|
|
Set the control's DropDownStyle to DropDownList
Charlie
if(!curlies){ return; }
|
|
|
|
|
|
I would like to make the following custom control.
A button, that opens a drop down list. Essentially, a combo box, but I don't want the appearance of a combo box. I want a button.
My initial problem is this. The drop down list may appear outside of its parent's bounds. Imagine a thin panel on the top of a form (like a toolbar) with this control attached to it. The control may have to draw the drop down list ON TOP OF the other controls immediately beneath the toolbar.
I'm used to something like css (position: absoloute). I guess the MainMenu does this. Do I need to custom draw the drop down list control?
Suggestions?
-Luther
|
|
|
|
|
Why not just use a ContextMenu , which is already supported? Just start tracking the ContextMenu in the coordinate space of the container of the Button so that it aligns properly with the Button in question. See the Control.PointToClient method to convert coordinate spaces back and forth. Because the Button.Location is already in the coordinate space of the container, you could also just add the Height and Width appropriately, saving you a lot of work. The ContextMenu control will also extend past the bounds of the container.
Otherwise, you can use a simple popup Window (with the WS_POPUP style when you consider the native implementation of most controls in the .NET BCL). This is all the ContextMenu is when you get the heart of it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heath.
Ddynamically placing the context menu might be just fine.
If I wanted more control over the look of the popup window, I may try the WS_POPUP window approach as well.
But, are you implying that I may have to use some native calls. I've written simple windows programs before - but I'm not exactly sure if thats what you mean.
Would I be on the right track to do this natively by - creating a WS_POPUP window and writing a wndproc to catch mouseover, mouse out and click events? I've seen several posts that link to native DLLs and use SendMessage, etc, so I think I could work this out.
But, I just want to be sure that I'm not missing something ... like, creating a panel in C# and somehow makeing it visible and invisible lower than the button I am using to trigger it. I've tried this - and at first attempt, the panel always shows up UNDERNEATH the controls lower in the client area.
I'm betting I can get that final idea could work if I could somehow make change the panel's z order to higher than the controls lower in the client area. The hypothetical problem I can think of is that the controls lower in the client area don't attach to the same parent, and so, maybe this is recursive so I need to trace back until the parents attach to the same form or root panel, and makes sure the popup menu parent is at a higher z index ...
If you have more time, your suggestions are greatly appreciated. For now, I'm off.
Thanks,
-Luther
|
|
|
|
|
A Panel won't work because it's a child window and nothing more. You have to use a popup window because it must be able to extend beyond its container's bounds. You could use a Form , but there's just too much overhead, IMO.
Yes, what I was talking about was good ol' Win32 programming. Fortunately, .NET can help even there. Remember that all the controls in System.Windows.Forms are just wrappers of Common Controls. There's even classes like NativeWindow that can give you a wrapper to a native window. It wouldn't be too difficult to do. I'm sure there's examples out there, too, although good, specific keywords might be hard to determine.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Perfect. You just saved me a night.
Thanks for the direction.
-Luther
|
|
|
|
|
Hi, Guru
I retrieve procedure parameter information by the code below.
OleDbConnection cnn = (OleDbConnection)idbConn;
OleDbCommand cmd = cnn.CreateCommand();
cmd.CommandText = "procedurename";//Procedure-Name
cmd.CommandType = CommandType.StoredProcedure;
OleDbCommandBuilder.DeriveParameters(cmd);
foreach(OleDbParameter par in cmd.Parameters)
{
MessageBox.Show(par.ParameterName + "\n" + par.Direction.ToString() + "\n" + par.OleDbType.ToString());
}
The problem is the provider not supported and return this error message...
"Retrieving procedure parameter information is not supported by the 'Microsoft.Jet.OLEDB.4.0' provider."
To do this, do you know what provider support.
Sorry for bad English.
Thank you.
|
|
|
|
|
What DataBase are you using ?
Free your mind...
|
|
|
|
|
The Microsoft Jet provider is used to access .mdb files, which are commonly equated with Microsoft Access, though MS Access is not needed to create and use these .mdb files (it's just really handy, and I believe required for forms and reports manipulation).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
So what's the question? The Microsoft Jet provider for .mdb files doesn't support retrieving parameters from stored procedures, which really are only module functions.
If you need a real RDBMS, look into the Microsoft Data Engine (MSDE) at http://www.microsoft.com/sql/msde/default.asp[^]. This is Microsoft SQL Server with a few limitations, like the number of concurrent connections supported (10). Other than that, it supports true stored procedures, triggers, tables and views (of course), functions, and everything else that SQL Server supports. It is also freely redistributable so long as you have a valid license for a product that includes the MSDE, like Visual Studio .NET, Microsoft Access (I think), an MSDN Subscription, and several others things. It's also a free download.
You can install up to 16 instances of the MSDE and SQL Server (think of them as the same thing). Microsoft Access even supports direct access and designing with the MSDE if you still want to design your databases using MS Access.
Basically, though, you get a real RDBMS that is much faster and supports everything any other RDBMS like Oracle and DB2 does. It also supports output parameters in stored procedures and has better support in .NET using the System.Data.SqlClient namespace, which is written specifically for SQL Server and you don't have to guess at what is supported. System.Data.OleDb is based on OLE DB and uses abstract OLE DB providers that must provide some basic functionality, but don't have to provide any of the optional stuff.
For instance, in an article I wrote I use the Microsoft Indexing Service OLE DB provider. It only supports basic SELECT statements and views using an OleDbCommand . Period. No updates, no insertions, no transactions, no stored procedures. You're left to the will of the OLE DB provider.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi, Guru
How to get list of Tables, Views and Procedure from Oracle database?
Thank You.
|
|
|
|
|
|
SELECT * FROM USER_TABLES
SELECT * FROM USER_VIEWS
SELECT * FROM USER_OBJECTS WHERE OBJECT_TYPE='PROCEDURE'
Free your mind...
|
|
|
|
|
I am writting a small application that works with remote server via http. My application sends a request and in return receives an xml file (i can access it via a string var.)
now I need to build a CheckedListBox with the data from this XML. Can someone suggest a simple way to arrange this and maybe give a sample?
my XML file looks like a lot of small containers that look like this (for each item):
<item>
<id>1</id>
<post_date>040104</post_date>
<subject>I posted a subject here!</subject>
<content>content is posted here</content>
</item>
<item>
I want to be able to build CheckedListBox with 4 rows: id, post_date, subject, content.
thanks a lot!
Alexander
|
|
|
|
|
First of all, design your XML document to reflect alternatives which are more like siblings. Because you have a fragment like:
<items>
<item>
<id>1</id>
<post_date>2004-01-03T00:00:00</post_date>
<!-- and the rest -- >
</item>
<item>
<id>2</id>
<post_date>2004-01-03T01:00:00</post_date>
<!-- and the rest -- >
</item>
</items> This implies that each item should be a separate row. This isn't absolute, but common. If you design your document like this, you could actually use DataSet.ReadXml and create a DataSet which is easily bindable to a CheckedListBox .
If you want to use your schema that you posted, you'll have to parse the XML document manually and create an IList or IListSource implementation. The easiest way would be to use an ArrayList , which implements IList . You can then use this object with the CheckedListBox.DataBindings property (if memory serves me correctly), or enumerate the list and add each item to the CheckedListBox.Items property. If you use the latter method, you can forego the ArrayList and just add the different XML elements to the CheckedListBox.Items property in the first place.
For information on multi-column CheckedListBox es, see the CheckedListBox.MultiColumn property documentation, which inherits from the ListBox control class.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
well, my XML file looks like what you have shown above: all <item></item> are stored withing one <news></news> so it looks like:
<news>
<item>
</item>
<item>
</item>
</news>
I made a mistake, I want to show the data in a datagrid, not a checkedlistBox. The problem is that this XML is actually a string...
I created a new dataset. how can I make dataset.ReadXml() read from a string?
many-many thanks!
Alexander.
|
|
|
|
|
dophka wrote:
I want to show the data in a datagrid, not a checkedlistBox.
Good, a DataGrid is easier to data-bind since you only have to use the DataSource property. You should also consider using the DataMember and TableStyles properties. See the SDK documentation for details or play around with the designer in VS.NET a little. It's not too difficult.
dophka wrote:
I created a new dataset. how can I make dataset.ReadXml() read from a string?
You'll need to read the fragment as a TextReader unfortunately. Let's say your XML fragment is in a string variable named xml :
StringReader reader = null;
DataSet ds = null;
try
{
reader = new StringReader(xml);
ds = new DataSet("news");
ds.ReadXml(reader);
}
finally
{
if (reader != null) reader.Close();
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thanks a lot for your explanations!
how I have done reading the xml thingy and I am sorry for asking, but then what? do I create another dataSet, add columns and then fill it with the data from the dataset that grabbed the xml content?
can you please please please walk me little further?
thanks!
Alexander
|
|
|
|
|
I'm the kind of guy that would rather teach a man to fish than give him a fish. So, read the documentation for the DataGrid . You already have your DataSet , so you assign that to the DataGrid.DataSource property and set the DataGrid.DataMember property to the table name you want to bind to. Columns are automatically created for each column of that table, but you can control this with the DataGrid.TableStyles property.
Try doing all this in VS.NET using the designer. Create a new DataSet schema then use the Data toolbox to add a new DataSet object. Add a DataGrid to your form or control and play around with some of the properties. Reading the documentation will fill in the details, which are important to understand.
There are also many great articles on data-binding here on CodeProject. Just use the search box toward the top and use generic terms like "DataSet" or "DataGrid". I'm sure you'll find plenty.
Besides, going into any great deal really isn't meant for the forums. With all the possibilities, this is better discussed in an article. Always be sure to read the documentation, though. It should be your first stop for any questions.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|