|
I tried to use Binding Context in the code to navigate and it doesnt work at all.
Do you have any better idea.
Thanks a lot
Looney
|
|
|
|
|
You've lost me completely here. A google for BindingContext in C# brought up the WinFX docs. Could you please explain exactly what you're doing - posting some code would be even better.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am creating a View(BrowseShip) and filling it in a dataset.
string sSQL = "Create VIEW BrowseShip AS SELECT A.CUST_CustomerICA, A.CUST_CustomerName..."
ds1 = new DataSet();
da1 = new SqlDataAdapter(sSQL, con);
da1.Fill(ds1, "BrowseShip");
And in MovePrevious click of button I am trying to do the below which actually throws the error...
this.BindingContext[this.ds1,"BrowseShip"].Position =
this.BindingContext[this.ds1, "BrowseShip"].Position - 1;
this.da1.Update(this.ds1);
I am not setting current position any where. I dont know anything abt navigation in .NET. In VB6 it was very simple...
Thanks in advance
Looney
|
|
|
|
|
> string sSQL = "Create VIEW BrowseShip AS
> SELECT A.CUST_CustomerICA, A.CUST_CustomerName..."
This statement is simply creating a view in the SQL Server database, which then you can query like a single table. You would create the view only once (for instance with SQL Server Query Analyzer) and then define a SELECT statement to use with the adapter :
(only once
string sSQL1 = "Create VIEW BrowseShip AS SELECT A.CUST_CustomerICA AS C_ICA, ...";
string sSQL2 = "SELECT C_ICA, ... FROM BrowseShip WHERE... ORDER BY...";
SqlCommand cmd = new SqlCommand(sSQL2, cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
cn.Open(); // Connection Open
da.Fill(ds, "BrowseShip");
cn.Close();
===
Hope this helps, the pro's here might correct me if I'm wrong...
|
|
|
|
|
I tried to do the way you explained...still it doesnt work...
It says cannot create a childlist for the field BrowseShip. BrowseShip is the view I created.
Do I need to bind controls on form to resultset like what we used to do in VB6...
Thanks
Looney
|
|
|
|
|
|
lovelylooney wrote:
I am not setting current position any where.
Well, in actual fact, the data grid will do the paging for you, if you turn the paging on. Otherwise, I've never seen code like this, only SQL code that returns only the current page of data.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am not using the datagrid. I wanted to navigate on a form that has text boxes and combo boxes. Now I am doing something like below...
cboShipmentRegion.DataBindings.Clear();
cboShipmentRegion.DataBindings.Add("Text",ds2,"BrowseShip.RGN_RegionCode");
txtBillICA.DataBindings.Clear();
txtBillICA.DataBindings.Add("Text",ds2,"BrowseShip.AST_ICA");
Anyways thanks for all the help. You have helped me more than once Christian.
Also thanks to oleman.
I am sure now, whenever I have some issue, I can count on you.
Thanks a billion
|
|
|
|
|
OK - so what paging are you doing if there is no grid ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a class that uses generics to have a typesafe DataSource property. I want to pass an instance of this class to a form and have it display the datasource. The code looks something like this:
public class DataSource<ItemType> where ItemType : StatefulObjectBase
{
public ItemType DataSource
{
....
}
public void Show()
{
DisplayForm f = new DisplayForm(this);
}
}
The question is, how do I code the parameter on the forms constructor. Using DataSource<StatefulObjectBase> doesnt work, even though the compiler should know that whatever is in the object is convertible to that type. Even using object didnt work.
All I want to do from the form is access some methods from my generic object. I dont care what type they are.
Any help would be much appreciated.
EDIT: oops, fixing generics.. damn less than and great thans
--
Dave
|
|
|
|
|
There are couple problems with this.
1. You cannot have public ItemType DataSource property as DataSource is name of the class
2. C# does supports generic methods, but not generic constructors.
You can write your code like:
<code>
public interface StatefulObjectBase
{
}
public class DataSource<ItemType> where ItemType : StatefulObjectBase
{
public ItemType TheDataSource
{
get { return default(ItemType); }
}
public void Show()
{
DisplayForm f = new DisplayForm();
f.Show<ItemType>(this);
}
}
public class DisplayForm
{
public DisplayForm()
{
}
public void Show<ItemType>(DataSource<ItemType> source) where ItemType : StatefulObjectBase
{
}
}
</code>
|
|
|
|
|
i am very new to c# and ASP.NET but i want to load audio files during application startup and play when button clicked. i got worked out how to do in windows forms with FileOpenDialog but i do not want openFileDialog in ASP.NET!
Any one with tips, hints please help!
Thank you
|
|
|
|
|
Where do you want to load audio files from ? If from the server, then an open file dialog will not help anyhow. If from the client, I'm not sure that you can. You can replace an openfiledialgo with a hardcoded path, but the real issue is where are the sound files, on the client or the server ? If on the server, then they can be played, but I'm at a loss as to why you're worried about a file browser ( which can't see the server anyhow ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
right now, i have all files in local computer. Some under http://localhost: and audio files in c:\My Documents folder. I have created all web forms with button to play Audio file but in windows forms it is ok by using OpenFileDialog and playback. Let say, in web forms using c# how could i load audio files and play back using button with out using FileOpenDialog?
Thank you Christian
I appreciated any help!
Thank you
abudicha
|
|
|
|
|
OK - so you want a webpage to load files off the users local computer, not off the server, and play them ? Why ? How can you browse to the users files without using a file browse dialog ? What are you hoping to have happen here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
right now, i want to know how can i load files when i just
run files from localhost as "http://localhost/webApp/default.aspx" to load audio files with out interaction with fileDialog?
I do not mind which folder will be? i can put under wwwroot or under IIS if necessary. But i need direction how to do it?
Thank Christian
I appreciated any helps
Adam Budicha
|
|
|
|
|
OK - so you're going to run them off the server. The but that I'm lost with is why you're talking about a file dialog. Do you want to allow the user to browse the music files ? A file dialog won't help here, the files are on the server.
Here[^] is an article on getting music files to play in a web page. ASP.NET has nothing to do with it, the browser needs to pass the file down in a format that the browser knows what to do with. I don't believe ASP.NET encapsulates that sort of behaviour in any classes, so you need to do it yourself.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I've added to my form a status bar and 2 panels.
The status bar is on the bottom, while the first panel is on the left the second panel is on the right.
I want the first panel is of 50 pixel always.
The second panel became bigger if the user resize the window.
It should attached to the first panel but the right follow the right of the window...
I would the status bar do that to... but i've not success neighter with the second panel nor the status bar...
why?
|
|
|
|
|
You'll probably have to size and position it yourself by responding to the forms resize event. Plan on spending a few hours Trial and erroring out magic numbers relating to border widths and the like. The form's size includes the border/menu/title bar space, pixel 0,0 is the upperleft most pixel inside/below all of that.
|
|
|
|
|
Need some help accesing methods of a parent form, from a child form.
How is this done?
|
|
|
|
|
if those methods are public, child form can siply keep reference to it's parent.. oh wait.. that should we be in Owner property of child form, if you display it with ShowDialog( IWin32Window ) overload of that method. If they are not public, can you make them public ? ( or internal )
David
|
|
|
|
|
A parent form is a form which is a MdiContainer. A child form can call its parent using childfrom.MdiParent.
==== Lei Ming 2004 =====
====================
|
|
|
|
|
Yes but the methods of the parent form are not shown using childform.MdiParent
What if i'm not using an MDI container?
|
|
|
|
|
You need to cast it the concrete class. i.e.
MyMainForm frm = Parent as MyMainForm;
60% of statistics are made up on the spot
|
|
|
|
|
Still not getting it.
This is my code:
In the MainForm (GameForm)...
BuyingForm f = new BuyingForm(new_item); //new instance of a "child" form
GameForm gameForm = Parent as GameForm;
f.Parent = gameForm;
f.Show();
In the ChildForm (BuyingForm)...
this.ParentForm.SomeMethod(); //the method is not listed
|
|
|
|