|
I am trying to work with the spliter class for my resize controls and i can not get how it works.
Can you help me and explain what it does and how it does it?
In my project i have 6 controlls that are in the form, i do not use panel,should I?
The form is very simple:
It has mainmanu and then toolbar and then in each corner of the form there is a controll, i mean
it looks like this:
mainmanu
toolbar
treeview lisbox
treevew listbox
How can i resize it all with the Spliter?
Thanks for you help[
|
|
|
|
|
You should use panels to do this. You must have at least two panels on your form. If you use VS 2005 than you can simply use SplitContainer control. If not then:
1. Add panel1 to the form and set panel1.Dock = Top.
2. Add splitter1 to the form and set splitter1.Dock = Top.
3. Add panel2 to the form and set panel2.Dock = Fill.
4. Add treeview1 to the panel1 and set treeview1.Dock = Left.
5. Add splitter2 to the panel1 and set splitter2.Dock = Left.
6. Add listbox1 to the panel1 and set listbox1.Dock = Fill.
7. Do steps 4-6 for the panel2.
|
|
|
|
|
Problem:
I want to insert into article table a new article. later insert articleid (Autoincrement) and category selected from checkboxlist (can be more than one category) into another table articlecategory.
Now i used a 'for' loop to iterate to insert into table articlecategory.\
now the problem is the table article is getting inserted twice with the first insert.
PLease enlighten me.
the code in C#:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace cmside
{
///
/// Summary description for article.
///
public class article : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnarticlesubmit;
protected System.Web.UI.WebControls.TextBox txtarticlename;
protected System.Web.UI.WebControls.TextBox txtarticletext;
protected System.Web.UI.WebControls.TextBox txtkeywords;
protected System.Web.UI.WebControls.TextBox txtsummary;
protected System.Web.UI.WebControls.CheckBoxList categorybox;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack==true)
{
SqlDataReader dr1;
SqlConnection con = new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=CMS");
SqlCommand cmd = new SqlCommand("select categoryID,categoryName from tblcategory",con);
con.Open();
dr1 = cmd.ExecuteReader();
this.categorybox.DataSource=dr1;
this.categorybox.DataTextField="categoryName";
this.categorybox.DataValueField="categoryID";
this.categorybox.DataBind();
dr1.Close();
con.Close();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.btnarticlesubmit.Click += new System.EventHandler(this.btnarticlesubmit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnarticlesubmit_Click(object sender, System.EventArgs e)
{
SqlConnection cn=new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=CMS");
SqlCommand cm=new SqlCommand("insert into tblarticle(articlename,athrid,articletext,articlekeywords,articlesummary) values('"+this.txtarticlename.Text+"','"+Request.QueryString["aid"]+"','"+this.txtarticletext.Text+"','"+this.txtkeywords.Text+"','"+this.txtsummary.Text+"');select @@identity as id;",cn);
cn.Open();
cm.ExecuteScalar();
cn.Close();
SqlDataAdapter da=new SqlDataAdapter(cm);
DataSet ds = new DataSet();
da.Fill(ds,"id");
int j = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
cn.Dispose();
cm.Dispose();
SqlConnection cn1=new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=CMS");
SqlCommand cmins= new SqlCommand("insertintoarticletocat",cn1);
cmins.CommandType=CommandType.StoredProcedure;
SqlParameter myparam = cmins.Parameters.Add("@categoryID",SqlDbType.Int);
SqlParameter myparam1 = cmins.Parameters.Add("@articleID",SqlDbType.Int);
for(int i = 0;i
|
|
|
|
|
Have you ever thought about creating a DAL (Data Abstraction Layer) to put all your database access in? It would make your code much tidier.
This is the offending code:
SqlConnection cn=new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=CMS");
SqlCommand cm=new SqlCommand("insert into tblarticle
(articlename,athrid,articletext,articlekeywords,articlesummary) values
('"+this.txtarticlename.Text+"','"+Request.QueryString["aid"]
+"','"+this.txtarticletext.Text+"','"+this.txtkeywords.Text+"','"+this.txtsummary.Text+"');select
@@identity as id;",cn);
cn.Open();
cm.ExecuteScalar();
cn.Close();
SqlDataAdapter da=new SqlDataAdapter(cm);
DataSet ds = new DataSet();
da.Fill(ds,"id");
First. It is suseptable to a SQL Injection Attack - You can find out what that is, how to recognise susceptable code and how to fix it here[^]
Second, the reason you are getting the row inserted twice is because you are asking it to get inserted twice.
This line inserts it the first time:
cm.ExecuteScalar(); And this line inserts it the second time:
da.Fill(ds,"id"); Why you are doing this I have no idea. It looks like you are trying to get the ID back out, but in doing so you are inserting the row twice.
The following should be sufficient:
int articleId = (int)cm.ExecuteScalar()
The remainder of the highlighted code after the cm.Close() can be removed.
Also, it looks like you are using a mix of styles, later in the code you are using a stored procedure. These conflicting styles will make code maintenance much more difficult in future. You should make a descicion to go all for stored srocedures (which is the option I recommend) or just don't use them at all.
Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?
My: Website | Blog
-- modified at 11:36 Saturday 15th July, 2006
|
|
|
|
|
Hi,
i have two files one in .txt format and other in .xls format,
i have matching set of data in both the files, my requirement is to compare and
check the accuracy of the records whether both reflect the same set of data,
based on the comparision result the corresponding records needs to be flagged, in both the
files for each record compared. can any one guide me how to approach to acheive this.
Note: Files needs to be read/updated at one shot
Thanks in advance
Krishna
|
|
|
|
|
Krrish wrote: at one shot
What does that mean "specifically"? It is not a technical term.
Krrish wrote: based on the comparision result the corresponding records needs to be flagged, in both the
files for each record compared.
flaged how? based on what results? You should just post your homework assignment since you are not very good at paraphrasing it.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
1)at one shot
*What does that mean "specifically"? It is not a technical term.
I mean the same function shoulad cater the requirement for both reading and updating the records
2)based on the comparision result the corresponding records needs to be flagged, in both the
files for each record compared.
*flaged how? based on what results? You should just post your homework assignment since you are not very good at paraphrasing it.
as i have mentioned i have 2 files containing matching records, i try to compare the accuracy of the set of records, when a record is matched i have a column "Matched" within the record, and i want to update that column based on comparision result,
ex: if a record in both files matches i update the column value as matched, otherwise as not-matched
in both the .txt and .xls files
Krishna
|
|
|
|
|
Krrish wrote: I mean the same function shoulad cater the requirement for both reading and updating the records
Ok well that is a really bad design but it's your project I guess.
Krrish wrote: i want to update that column based on comparision result,
If the character width of the column is not going to change then you can just set the "file position" and then overwrite the column data with the new bytes. If the data width is going to change then it is much more complex because you have to write the entire file from the first position that changes the data width.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
is there any way that i can do sql operations to update the content,
am able to get the whole content by querying
string sqlstring = "SELECT * FROM temp.txt";<br />
string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Shared\ExportAndDisplayData\;Extended Properties=Text;";<br />
OleDbConnection objConn = new OleDbConnection(sConnectionString); <br />
objConn.Open();<br />
OleDbCommand objCmdSelect = new OleDbCommand(sqlstring, objConn); <br />
objAdapter1.SelectCommand = objCmdSelect; <br />
DataSet objDataset1 = new DataSet();<br />
objAdapter1.Fill(objDataset1, "Test"); <br />
DataTable dt1 = objDataset1.Tables[0];
Thanks in advance
Krishna
|
|
|
|
|
call this function when delete record
function pagecount()
{
if(dgDocument.CurrentPageIndex >0)
{
dgDocument.CurrentPageIndex=dgDocument.CurrentPageIndex-1;
}
else
{
dgDocument.CurrentPageIndex=0;
}
}
vijay jain
|
|
|
|
|
|
What is your problem or question?
|
|
|
|
|
Is there any way to read the file that a .lnk (shortcut) refers to? Opening the file in Notepad shows that it is not plain text (such as Adobe Gamma Loader.lnk which loads Program Files\Common Files\Adobe\Calibration\Adobe Gamma Loader.exe). I am wondering if there is any way to read a .lnk file's location using some sort of library.
Thanks,
Josh
|
|
|
|
|
You can use the Windows Script Host Object Model COM library for this. If you're using Visual Studio, add a reference to it by selecting the COM tab from the Add Reference dialog and select "Windows Script Host Object Model". This will create an interop assembly called Interop.IWshRuntimeLibrary and will reference that. Then you can use the following code to extract the target file from a .lnk file...
<span style="color: blue;">using</span> IWshRuntimeLibrary;
...
WshShell shell = <span style="color: blue;">new</span> <span style="color: teal;">WshShell</span>();
<span style="color: teal;">IWshShortcut</span> link = (<span style="color: teal;">IWshShortcut</span>)shell.CreateShortcut( linkPath ); <span style="color: green;">
<span style="color: teal;">Process</span>.Start( link.TargetPath ); <span style="color: green;"> Hope that helps
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent
Cheers,
Will
|
|
|
|
|
Thanks for the help Will. It works great.
-Josh
|
|
|
|
|
The title says it!
Your help would be greatly appreciated.
|
|
|
|
|
Hi, do you use AxWebBrowser? If yes then webBrowser.Navigate("some.mht", ...) will do this work.
|
|
|
|
|
I have a custom control that has a StringCollection property:
private StringCollection _images = new StringCollection();
[Category("_Hotspot"),
TypeConverter(typeof(StringCollectionConverter)),
EditorAttribute("System.Windows.Forms.Design.StringCollectionEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing")]
public StringCollection Images
{
get {return _images;}
set {_images = value;}
}
I want to be able to edit it at design time, so I wrote a type converter to translate it into a string and back in the attribute:
public class StringCollectionConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;
else
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(StringCollection))
return true;
else if (destinationType == typeof(InstanceDescriptor))
return true;
else
return base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is string)
{
string[] v = ((string)value).Split(new char[] {','});
StringCollection stringList = new StringCollection();
for (int i=0; i<v.Length; i++)
{
stringList.Add(v[i]);
}
return stringList;
}
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
StringCollection stringList;
if (destinationType == typeof(string))
{
stringList = (StringCollection)value;
string result = "";
for (int i=0; i<stringList.Count; i++)
{
result += stringList[i];
if (i < stringList.Count - 1)
result += ",";
}
return result;
}
else if (destinationType == typeof(InstanceDescriptor) && value is StringCollection)
{
stringList = (StringCollection)value;
ConstructorInfo ctor = typeof(StringCollection).GetConstructor(new Type[] {});
if (ctor != null)
return new InstanceDescriptor(ctor, new object[] {});
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
I'm able to click the elipse in the editor, bring up the string collection editor, and enter strings. The strings are written out properly as a comma delimited list in the attribute of the control, but when I run the app, those values are never initialized into the string collection at runtime.
This seems like a lot of work to have a simple collection of strings as a property. Does anyone know how to make this work? I've been searching the web trying to figure this out for days. Lots of people ask about it, but no-one really seems to have the answer. Thanks.
Jason
|
|
|
|
|
Hi,
you would have much less work to change your property to type string[] . This one is fully supported by the IDE. If you still need the collection you could just make a second one which just acts as a wrapper for the designer and internally modifies the collection.
|
|
|
|
|
If I try to use string[] for the property, after I populate it in the editor at design time and switch to look at the source, it writes the attribute as "String[] Array". What do you mean, it's fully supported by the IDE?
|
|
|
|
|
Yes it is. The TextBox has a Lines property which behaves exactly the same way. Notice the little '+' left of the text 'String[]-Array'? Click it you'll see all single elements of the array.
|
|
|
|
|
There's no + sign next to the property in the property grid. There is an elipse to the right of it that brings up a "String collection editor," which I did not specify.
Like I said before, it writes 'String[]-Array' as the attribute for the property in the SOURCE CODE of the page. The strings themselves do not get recorded properly in the source of the page.
I'm using VS 2005, if that makes a difference.
I'll try adding a typeconverter, but I feel like I'm just going back down the same road I took with the StringCollection type.
Edit: After I populate the array in the string collection editor, I do see a + next to the array in the editor, as you said. But it still doesn't populate it in the source properly.
Edit: I got it working! It turns out there's a prebuilt type conerter for string arrays, and I just had to specify it above the property:
TypeConverter(typeof(StringArrayConverter))
Now everything propagates properly. Thanks for the advice!
-- modified at 13:15 Thursday 20th July, 2006
|
|
|
|
|
The only thing I can think of is that this somehow behaves different in web application (I don't know why it should though). I've just tested it for a winapp and it works...
|
|
|
|
|
Hello,
is it possible to launch an other program,
for example notepad as MDI Child in your programs MDI Parent?
Im making a funny Fake OS for my friend and it would be cool if this is possible.
I hope someone can help me,
Thanks
|
|
|
|
|
No, it isn't.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|