|
I'm adding a new column to a dataset with the following:
dataset.Tables[0].Columns.Add("boollist",Type.GetType("System.Boolean"));
and when i show it in a datagrid there are three possible selections in it: true (a cross in the box), false (no cross), and something else when the box is grey with a cross in it.. i guess it means null or something.. how can i make it so that the user only gets true or false on clicking in the checkbox, never the grey selection?
thanks!
|
|
|
|
|
You can either derive your own DataGridColumnStyle and use an actual ComboBox with tri-state disabled (default), or make sure that the column bound to the DataGridBoolColumn never has nulls (like, don't allow nulls in the database or in your DataSet , which you can configure when dynamically creating a DataSet or - better yet - to create a typed DataSet in VS.NET which is easy - just add a new "DataSet" class to your project and design it or drag-n-drop tables from the Server Explorer if you have a connection to your DB established). When you create that field in your table for a typed DataSet , there is an option to disallow nulls.
The default DataGridBoolColumn draws a tri-state combobox (doesn't use the actual ComboBox control) if nulls are present (or allowed), but draws a simple combobox if there isn't.
You can further control this by explicitly defining table and colum styles for the DataGrid . See the DataGrid.TableStyles documentation for details and an example. VS.NET's DataGrid designer makes this a trivial task, especially when you've added an instance of a typed DataSet to your designer component surface.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello.
I'v made a user control with a ListView and a ListBox . So I use that whole control as a component.
With the code below I'm able to set the ListBox's DataSource at design time. I can also see property fields for ValueMember and DisplayMember . But the property comboboxes won't pop up.
On the web, I've found code like mine that is said to work fine. The only difference is that I use a ListBox instead of a ComboBox control.
Is there any List, Collection, interface, EventHandler or something like this I've forgotten?
[Category("RUCListBox"),<br />
Bindable(true),<br />
Description ("Apply datasource"),<br />
RefreshProperties(RefreshProperties.All),<br />
TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design"),<br />
]<br />
public object RucDataSource<br />
{<br />
get{return listBox1.DataSource;}<br />
set{this.listBox1.DataSource = value;}<br />
}<br />
[Category("RUCListBox"),<br />
RefreshProperties(RefreshProperties.All),<br />
Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design",<br />
"System.Drawing.Design.UITypeEditor, System.Drawing"),]<br />
public string RucValueMember <br />
{<br />
get { return this.listBox1.ValueMember; }<br />
set { this.listBox1.ValueMember = value; }<br />
}<br />
[Category("RUCListBox"), Bindable(true),<br />
Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design",<br />
"System.Drawing.Design.UITypeEditor, System.Drawing"),]<br />
public string RucDisplayMember <br />
{<br />
get { return this.listBox1.DisplayMember; }<br />
set { this.listBox1.DisplayMember = value; }<br />
}<br />
<br />
public override System.Windows.Forms .BindingContext BindingContext <br />
{<br />
get { return BindingContext; }<br />
}
T. Labenche
|
|
|
|
|
Do you mean you can't see the IntelliSense drop-downs for your properties at design-time? Try typing them in anyway and compile. If it works, don't worry about it. There is documented cases where VS.NET fails to display everything in the drop-down because of various problems. Typically, restarting VS.NET helps.
If it doesn't compile, it sounds like you have a access problem. While your properties are public, the class could be internal so that another assembly (and by extension, another project) wouldn't be able to access to class (and by extension, it's properties).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I don't have much experience in this area, but I thought I'd try to give you a hand anyway.
Looking here[^] caused me to wonder if you don't need to add (or change) a property to use the DataMemberListEditor in order to trigger the use of the DataMemberFieldEditor that you are trying to use.
If that doesn't help, then this link might supply additional information, or a different approach that will help: http://www.codeproject.com/aspnet/webcontrolsdatabinding.asp[^]
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi, im trying to store multiple items from a listbox / checklistbox to a column in a database.. storing them is a breeze(i think)
but the tricky part is how do i retrieve them into
(1) textbox(es) or
(2) listbox. like below :
1. item1
2. item2
3. item3
4. item4 and so on..
instead of item1,item2,item3,item4.....and on..
do i have to use a loop or is there a better way to go about this..pls help..
CODER
|
|
|
|
|
Look for Control.DataBindings Property in MSDN. There is an example there too.
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
You can also find many samples of data-binding in the .NET Framework SDK, .NET Samples - Windows Forms: Data Binding[^].
Data-binding allows you to take a data source (a DataSet is a common and rich source), assign that to a control's DataSource property (if it has one, like the DataGrid ), set a few other properties and that's it (in ASP.NET, it requires a call to a DataBind method). You can data-bind just about anything, though. The DataBindings property allows you to manually (not quite as easy as what I described above, but do-able) binding a control's properties to a data source. The .NET Framework provides data-binding "managers" for data sources and for properties (so you could binding two controls' properties together). See the documentation for the BindingManagerBase[^] class in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How would I go about creating a new window UI in VS.net for C#?
An article or something to point me in the right direction would be appreciated. If you need any more information about what I'm trying to accomplish, don't hesitate to ask.
|
|
|
|
|
authenticgeek wrote:
If you need any more information about what I'm trying to accomplish, don't hesitate to ask.
We're asking... What do mean by "create a new window UI"?
RageInTheMachine9532
|
|
|
|
|
Modifying the look of the windows.
The grey and gradient blue isn't aesthetically pleasing to me and I'd like to do more than just change the current Windows theme. Perhaps I'll change the location of the close, resize and minimize buttons as well and use different icons for those.
Is this something that can be done with .net and C#?
|
|
|
|
|
It could be done, but it is FAR from a trivial task. You'd be writing an entirely new Windows Shell.
You might want to look here[^] for some examples first, before you go down the road of rewriting Explorer.exe.
RageInTheMachine9532
|
|
|
|
|
I see what you're saying but what if I just want to change the appearance of the application I'm creating? The easiest example is iTunes for Windows. It looks pretty much like it does on OS X but on any windows machine.
Does this make things easier?
|
|
|
|
|
That simplifies things bit. Owner drawn forms...Hmmm...
I'd follow Heath's advice and go for overriding WndProc. I've never done an owner drawn form, so I don't know if the Framework Form class will let you do that.
Heath, got any insight?
RageInTheMachine9532
|
|
|
|
|
It's not something easily done in C# (or any .NET language) because the non-client areas of a Window are not exposed directly. All the controls (including forms) "simply" encapsulate the Windows Management and Common Control APIs. You can often change this behavior by overriding WndProc and handling notification messages (like WM_NCPAINT ) to change the behavior. Often times, you must P/Invoke a lot of native methods (like SendMessage ) and re-declare various necessary structs and consts. It can be done, but like the other post said, it's not trivial. Win32 programming experience will definitely be helpful. Learn first how to do it in C/C++ since you won't have to redeclare everything you need (since it's all defined in the headers you'd require). You should also consider using Managed C++ in mixed mode compilation because you can easily use the native APIs without having to P/Invoke them. This would produce an unverifiable assembly, though, but that's not a problem when running from the local machine.
Search CodeProject for examples of how to override WndProc . A common implementation is to override WndProc for the ListView (which enscapsulates the List-View common control) to provide various things that Windows Forms does not expose.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i think theres a namespace called Design for changing the controls in the design time, search for it if it could help
|
|
|
|
|
i m doing a HttpResponse to an url, every response is put in a thread, the problem is the variables i used in the AsyncResult, already i asigned an array of variables, i want to send the index of that variable to the thread, how can i do this?
|
|
|
|
|
You might want to post a code sample of what you doing. The description you gave is disjointed and is very difficult to picture what your doing.
RageInTheMachine9532
|
|
|
|
|
Here's the code i wrote
<br />
int i = 0;<br />
while(DataReader.Read())<br />
{<br />
url[i] = new String('u',1);<br />
<br />
DateIn[i] = new object();<br />
<br />
UserID[i] = DataReader.GetInt32(0);<br />
url[i] = DataReader.GetString(1);<br />
DateIn[i] = DateTime.Now;<br />
<br />
Req = (HttpWebRequest)WebRequest.Create(url[i]);<br />
<br />
<br />
<br />
CallBack = new AsyncCallback(AsCallBack);<br />
i++;<br />
Req.BeginGetResponse(CallBack,null);<br />
}<br />
and heres the call back function
<br />
private void AsCallBack(IAsyncResult ar)<br />
{<br />
try<br />
{<br />
DateOut = new String('S',1);<br />
Status = new String('T',1);<br />
Res = (HttpWebResponse)Req.EndGetResponse(ar);<br />
DateOut = ((TimeSpan)(DateTime.Now - (DateTime)DateIn[i])).ToString();<br />
Status = Res.StatusCode.ToString();<br />
}<br />
catch(HttpException er)<br />
{<br />
Status = er.GetHtmlErrorMessage();<br />
}<br />
catch(WebException er)<br />
{<br />
Status = er.Status.ToString();<br />
}<br />
catch(Exception er)<br />
{<br />
Status = er.Message;<br />
}<br />
thx for ur help
|
|
|
|
|
First, instead of threading these yourself, use the Begin* and End methods. You'll get an IAsyncResult implementation back. You could possibly use the AsyncState to set new data, but you must be careful because the thread might be done so it won't matter, or you may corrupt the data that the async thread is using. Typically, you give a thread everything it needs before it starts the the thread is responsible for querying a source for anything else it might need during execution (like a database, online resource, callback, etc.).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I created a Asp Web Application. I try to print my job with printdocument.
But I always failed.
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.PrinterSettings.PrinterName = "EPSON LP-8600F";
pd.Print();
......
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
......
}
My Program don't Normally Work.
Can who tell me is it why ?
Thanks.
|
|
|
|
|
Why don't you use javascript... window.print();
This doesn't give you server-side processing at print-time, but you can make that work by using a Button . Just have the click handler register the above javascript using the Page.RegisterClientScriptBlock(string, string) method.
I'm not sure exactly what you're trying to achieve, but I hope this works.
Michael Flanakin
Web Log
|
|
|
|
|
My program had worked.But there were not What i want to be result.
The Text's endcoding were wrong.
I try to much font,but this wrong still are exists.
|
|
|
|
|
What are you trying to print?
Michael Flanakin
Web Log
|
|
|
|
|
Are you trying to print on the server or the client? If you're trying to print on the server, then you must make sure that the user account under which ASP.NET runs (the local ASPNET user account by default) has the printer set up. You must also make sure that the user has rights to print to the printer. If you search this forum (click "Search comments" above), this has been covered in the past.
If you're trying to print on the client, this won't work. ASP.NET involves server-side execution, minimally using client-side javascript and elements/attributes to do its job. You can't execute code like this on the server and expect anything to happen on the client. In this case, the other post above this (the first reply you got) is the way to do it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|