|
How to split them. The insert or Update statement is not allowed in case statement.
|
|
|
|
|
Uma Kameswari wrote: How to split them. The insert or Update statement is not allowed in case statement
Don't use single statement. Create a different insert statement and different update statement and execute both separately. Instead of using case in select, use where conditions, like:
insert into table (columns)
select columns
from anothertable
where ConditionsToBeMet and
update table
set columns
where ConditionsToBeMet Just make the conditions so that they define the logic you defined in case statement.
|
|
|
|
|
Will it be feasible to create and add in for visual studio which can draw with a sketch on the coding window.
|
|
|
|
|
|
Hello
I have this small but confusing exercise and what i want to do is when form loads it displays all the widgets in one listbox(small and big) and in second one I just want to display small widgets so could you please help me with this
code is as bellow
Imports System.Collections.Generic
Imports System.Text
Imports System.Collections
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim colBoxesOfWidgets As New ArrayList()
colBoxesOfWidgets.Add(New BoxOfWidgets("Cardboard"))
DirectCast(colBoxesOfWidgets(0), BoxOfWidgets).colWidgets.Add(New Widget("The Blue Widget", 12))
DirectCast(colBoxesOfWidgets(0), BoxOfWidgets).colWidgets.Add(New Widget("The Red Widget", 15))
DirectCast(colBoxesOfWidgets(0), BoxOfWidgets).colWidgets.Add(New Widget("The Silver Widget", 6))
DirectCast(colBoxesOfWidgets(0), BoxOfWidgets).colWidgets.Add(New Widget("The Green Widget", 52))
colBoxesOfWidgets.Add(New BoxOfWidgets("Metal"))
DirectCast(colBoxesOfWidgets(1), BoxOfWidgets).colWidgets.Add(New Widget("The Gold Widget", 9))
DirectCast(colBoxesOfWidgets(1), BoxOfWidgets).colWidgets.Add(New Widget("The Orange Widget", 115))
DirectCast(colBoxesOfWidgets(1), BoxOfWidgets).colWidgets.Add(New Widget("The Pink Widget", 1))
colBoxesOfWidgets.Add(New BoxOfWidgets("Metel"))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The Grey Widget", 12))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The Black Widget", 15))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The White Widget", 19))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The Brown Widget", 60))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The Peach Widget", 16))
Call GetRidOfTheSmallWidgets(colBoxesOfWidgets)
End Sub
Public Function GetRidOfTheSmallWidgets(ByVal colBoxesOfWidgets As ArrayList) As ArrayList
For J As Integer = 0 To colBoxesOfWidgets.Count - 1
ListBox1.Items.Add(DirectCast(colBoxesOfWidgets(J), _
BoxOfWidgets).colWidgets.Add(J))
Next :confused:
Return (colBoxesOfWidgets)
End Function
End Class
Class BoxOfWidgets
Public boxType As String
Public colWidgets As ArrayList
Public Sub New(ByVal newBoxType As String)
boxType = newBoxType
colWidgets = New ArrayList()
End Sub
End Class
Class Widget
Public name As String
Public length As Single
Public Sub New(ByVal newName As String, ByVal newLength As Single)
Me.name = newName
Me.length = newLength
End Sub
End Class
and problem with this is it loads the items in to listbox but only numbers I mean how many widgets are there in each boxof widgets but i want to display all the widgets from all boxes
waiting for your kind help
|
|
|
|
|
Hi,
I have a ComboBox Column in DataGridView and also I use Cell Formatting event to change the Images dynamically in the DataGridViewImage Column based on business validations.
I am not able to retain the selected item value in the Combobox cell, it is disappearing because of Cell Formatting event always fires and re-instantiates the combo cell to default value.
If I disable Cell Formatting event code, I can see the value is retained in the combobox cell and it works
Please let me how to solve this issue, because I have to use Cell Formatting evetn for various conditions, So I can not disable the code.
give an idea or code sample to retain selected values in the combo cells on usage cell formatting event
Thank you
Shyam Sundar
|
|
|
|
|
I've done a simple custom label in .net 2.0 that allows a border color to be set. The problem is I can't get the control to repaint if another form is dragged over the control. I've tried the SetStyle() method and it doesn't seem to help.
public partial class BorderLabel: Label
{
public BorderLabel()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);
}
private Color _borderColor = Color.Black;
public Color BorderColor
{
get { return _borderColor; }
set
{
_borderColor = value;
Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int borderWidth = 1;
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, _borderColor,
borderWidth, ButtonBorderStyle.Solid, _borderColor, borderWidth,
ButtonBorderStyle.Solid, _borderColor, borderWidth, ButtonBorderStyle.Solid,
_borderColor, borderWidth, ButtonBorderStyle.Solid);
}
}
What other events should I be overriding to cause the control to repaint when a form is dragged over the control?
|
|
|
|
|
Change your ControlPaint to "e.Graphics":
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int borderWidth = 1;
e.Graphics.DrawBorder(e.Graphics, e.ClipRectangle, _borderColor,
borderWidth, ButtonBorderStyle.Solid, _borderColor, borderWidth,
ButtonBorderStyle.Solid, _borderColor, borderWidth, ButtonBorderStyle.Solid,
_borderColor, borderWidth, ButtonBorderStyle.Solid);
}
Use the Graphics object you are given in the event arguments, not your own.
|
|
|
|
|
Thanks but what fixed it was not using the e.ClipRectangle, but using the ClientRectangle object instead.
|
|
|
|
|
You know, I didn't even read into the entire line. I just looked at the beginning of it and said "wait a minute...". I was runnig short on time this morning.
|
|
|
|
|
dear friends,
i need your help,Now i am creating billingual Apllication how to change the date time in english and arabic for run time
Thanx
R.Arun
|
|
|
|
|
excellent, look into resource files.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Dear Friends,
Here I Search All resource file Posiblities Change Font in to Arabic it is not working.Any other ideas about that please share with me.
Thanks
Arun.R
|
|
|
|
|
Hello
This is one exercise in OOP lesson ,but still I am bit confuse how to get rid of small widgets, and what I want to do is when form loads it displays small widgets(<= 20) in one listbox and and rest in second listox, any help, In Public Function GetRidOfTheSmallWidgets I have put loop but it's only displays 0,1,2 so how can i add small widgets in one listbox and big ones in second listbox
Imports System.Collections.Generic
Imports System.Text
Imports System.Collections
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim colBoxesOfWidgets As New ArrayList()
colBoxesOfWidgets.Add(New BoxOfWidgets("Cardboard"))
DirectCast(colBoxesOfWidgets(0), BoxOfWidgets).colWidgets.Add(New Widget("The Blue Widget", 12))
DirectCast(colBoxesOfWidgets(0), BoxOfWidgets).colWidgets.Add(New Widget("The Red Widget", 15))
DirectCast(colBoxesOfWidgets(0), BoxOfWidgets).colWidgets.Add(New Widget("The Silver Widget", 6))
DirectCast(colBoxesOfWidgets(0), BoxOfWidgets).colWidgets.Add(New Widget("The Green Widget", 52))
colBoxesOfWidgets.Add(New BoxOfWidgets("Metal"))
DirectCast(colBoxesOfWidgets(1), BoxOfWidgets).colWidgets.Add(New Widget("The Gold Widget", 9))
DirectCast(colBoxesOfWidgets(1), BoxOfWidgets).colWidgets.Add(New Widget("The Orange Widget", 115))
DirectCast(colBoxesOfWidgets(1), BoxOfWidgets).colWidgets.Add(New Widget("The Pink Widget", 1))
colBoxesOfWidgets.Add(New BoxOfWidgets("Metel"))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The Grey Widget", 12))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The Black Widget", 15))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The White Widget", 19))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The Brown Widget", 60))
DirectCast(colBoxesOfWidgets(2), BoxOfWidgets).colWidgets.Add(New Widget("The Peach Widget", 16))
Call GetRidOfTheSmallWidgets(colBoxesOfWidgets)
End Sub
Public Function GetRidOfTheSmallWidgets(ByVal colBoxesOfWidgets As ArrayList) As ArrayList
For I As Integer = 0 To colBoxesOfWidgets.Count - 1
lstWidgets.Items.Add(I).ToString()
Next
Return (colBoxesOfWidgets)
End Function
End Class
Class BoxOfWidgets
Public boxType As String
Public colWidgets As ArrayList
Public Sub New(ByVal newBoxType As String)
boxType = newBoxType
colWidgets = New ArrayList()
End Sub
End Class
Class Widget
Public name As String
Public length As Single
Public Sub New(ByVal newName As String, ByVal newLength As Single)
Me.name = newName
Me.length = newLength
End Sub
End Class
|
|
|
|
|
You are dealing with an ArrayList that contains BoxOfWidgets instances. The ArrayList is populated with only 3 BoxOfWidgets instances: Cardboard, Metal and Metel. Each BoxOfWidgets instance has it's own internal ArrayList named colWidgets . Perhaps your intention is to iterate over the internal collections of each BoxOfWidgets :
For I As Integer = 0 To colBoxesOfWidgets.Count - 1
For J As Integer = 0 To DirectCast(colBoxesOfWidgets[I], BoxOfWidgets).colWidgets.Count - 1
lastWidgets.Items.Add(J).ToString()
Next
Next
Last, I'd also recommend using the Generic List rather than an ArrayList as it will perform better.
Keep It Simple Stupid! (KISS)
|
|
|
|
|
hello sir
Yes it works but it only displays o,1,2,3 numbers in listbox not name or length of widgets
waiting for your kind rep.
|
|
|
|
|
The reason you only see numbers in the ListBox is because the following loop is adding the integer I to the list box on each pass:
For I As Integer = 0 To colBoxesOfWidgets.Count - 1
lstWidgets.Items.Add(I).ToString()
Next
So, you probably want something like this:
For I As Integer = 0 To colBoxesOfWidgets.Count - 1
lstWidgets.Items.Add((DirectCast(colBoxesOfWidgets(I), BoxOfWidgets).boxType)
Next
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Hello sir
thanks for your rep.
yes it works but still i am not getting all the lists for widgets like it shows box of widgets but it's not showing what's in there in each box so I have tried this and it shows how many widgets are there in each box but not name of that widgets i am getting there but still need to do some thing little to get there
so this is what i have done
For J As Integer = 0 To colBoxesOfWidgets.Count - 1
ListBox1.Items.Add(DirectCast(colBoxesOfWidgets(J), _
BoxOfWidgets).colWidgets.Add(J))
Next
so i think i need to get class widget to get name and length for each widgets but i am lost
waiting for your kind rep.
have a nice day
|
|
|
|
|
I have a multithreaded application, and want to access a ListBox from multiple threads. However, if i add an item to the ListBox from a thread different from the one it was created in, the changes are only shown, once i trigger a refresh from the creation thread. Is there any way around that ?
|
|
|
|
|
|
Thanks, i also found help here[^].
|
|
|
|
|
Nice to see that you got it working
|
|
|
|
|
You have to use BeginInvoke method of the control while modifying the controls' property from a different thread other than which the control was created on.
refer the link
http://msdn.microsoft.com/en-us/library/a06c0dc2.aspx
hope it solves ur problem
|
|
|
|
|
I'm trying to write a Custom Panel that draws contained controls with mixed art stuffs (rectangles, circles, triangles). I've done it very well, the problem comes when I implement double buffering. Here's my code
class BgPanel : System.Windows.Forms.Panel
{
//....
private Image buffer;
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(buffer, 0, i);
}
private void RenderToBuffer()
{
Graphics g = Graphics.FromImage(buffer);
foreach(Control c in Controls){
DrawArts(g); // draw some colored shapes
//********************
How do I draw each control into buffer?
//********************
DrawArts(g);
}
}
//....
}
My problem is that I don't know how to draw each control inside the panel into buffer image. Could anyone please help me with this?
I'm working on .NET CF 3.0, by the way.
Thanks,
iSoft of Technomation
modified on Sunday, December 7, 2008 6:13 PM
|
|
|
|
|
|